package e.planner;

import e.planner.funcoes;
import e.planner.compromissos;
import e.planner.horario;
import e.planner.aula;
import e.planner.interrupcoes;
import e.planner.tarefas;
import e.planner.BotaoAlt;

import com.toedter.calendar.JCalendar;
import com.toedter.calendar.JDateChooser;
import com.toedter.calendar.JDayChooser;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.FileNotFoundException;

import java.io.File;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.BorderFactory;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;

public class GUI extends javax.swing.JFrame {
    String DataInicioSemestre;
    String DataFimSemestre;
    String DataInicioInterrupcao;
    String DataFimInterrupcao;
    
    public ArrayList<compromissos> arrayCompromissos = new ArrayList<compromissos>();
    public horario arrayHorario;
    private int flagHorario=0;
    private int newFlagHorario=0;
    public ArrayList<tarefas> arrayTarefas = new ArrayList<tarefas>();
    
    JScrollPane panelCompromissos = new JScrollPane();
    private ArrayList<JLabel> labelsCompromissos = new ArrayList<JLabel>();
    private ArrayList<BotaoAlt> buttonsCompromissos = new ArrayList<BotaoAlt>();
    
    JScrollPane panelTarefas = new JScrollPane();
    private ArrayList<JLabel> labelsTarefas = new ArrayList<JLabel>();
    private ArrayList<JButton> buttonsTarefas = new ArrayList<JButton>();

    private int IndiceEliminarTarefa;
    private int IndiceEliminarCompromisso;
    private String DataEliminarCompromisso;
    private String DataAux;
    private String DataAux2;
    private String DiaSemana;
    
    
    public GUI() throws ParseException {
        initComponents();
        setLocationRelativeTo(null);
        LeTarefas();
        LeCompromissos();
        LeHorario();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        JanelaCompromissos = new javax.swing.JDialog();
        Calendario1 = new com.toedter.calendar.JCalendar();
        LabelCompromissos = new javax.swing.JLabel();
        BotaoAddCompromisso = new javax.swing.JButton();
        FormCompromisso = new javax.swing.JDialog();
        jLabel7 = new javax.swing.JLabel();
        LabelHoraInicio = new javax.swing.JLabel();
        LabelHoraFim = new javax.swing.JLabel();
        LabelLocal = new javax.swing.JLabel();
        LabelCompromisso = new javax.swing.JLabel();
        TextFieldLocal = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jScrollPane8 = new javax.swing.JScrollPane();
        ListaHIcompromisso = new javax.swing.JList();
        jScrollPane9 = new javax.swing.JScrollPane();
        ListaHFcompromisso = new javax.swing.JList();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jScrollPane10 = new javax.swing.JScrollPane();
        ListaMIcompromisso = new javax.swing.JList();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jScrollPane11 = new javax.swing.JScrollPane();
        ListaMFCompromisso = new javax.swing.JList();
        jScrollPane12 = new javax.swing.JScrollPane();
        TextAreaCompromisso = new javax.swing.JTextArea();
        JanelaVisualizacaoTarefas = new javax.swing.JDialog();
        LabelTarefas = new javax.swing.JLabel();
        JanelaAddTarefas = new javax.swing.JDialog();
        jLabel6 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        BotaoAddTarefa = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        TextAreaTarefa = new javax.swing.JTextArea();
        JanelaPreenchHorario = new javax.swing.JDialog();
        LabelHorario = new javax.swing.JLabel();
        LabelInicioSemestre = new javax.swing.JLabel();
        LabelFimSemestre = new javax.swing.JLabel();
        DateChooserInicioSem = new com.toedter.calendar.JDateChooser();
        DateChooserFimSem = new com.toedter.calendar.JDateChooser();
        BotaoContinuarPreench = new javax.swing.JButton();
        JanelaInterrupcoes = new javax.swing.JDialog();
        LabelInicioInt = new javax.swing.JLabel();
        javax.swing.JLabel LabelInicioInterrupcao = new javax.swing.JLabel();
        LabelFimInterrupcao = new javax.swing.JLabel();
        DateChooserFimSem2 = new com.toedter.calendar.JDateChooser();
        jDateChooser4 = new com.toedter.calendar.JDateChooser();
        BotaoContinuaPreench2 = new javax.swing.JButton();
        FormularioAula = new javax.swing.JDialog();
        LabelAula = new javax.swing.JLabel();
        LabelDiaSemana = new javax.swing.JLabel();
        LabelNomeAula = new javax.swing.JLabel();
        TextFieldNomeAula = new javax.swing.JTextField();
        LabelTipo = new javax.swing.JLabel();
        LabelInicioAula = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        ListaHoraInicio = new javax.swing.JList();
        jScrollPane4 = new javax.swing.JScrollPane();
        ListaMinutosInicio = new javax.swing.JList();
        LabelFimAula = new javax.swing.JLabel();
        BotaoAddAula = new javax.swing.JButton();
        jScrollPane7 = new javax.swing.JScrollPane();
        ListaHoraFim = new javax.swing.JList();
        LabelH = new javax.swing.JLabel();
        LabelH2 = new javax.swing.JLabel();
        LabelM = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        ListaMinutosFim = new javax.swing.JList();
        LabelM2 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        ListaTipoAula = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        ListaDias = new javax.swing.JList();
        jLabel1 = new javax.swing.JLabel();
        TextFieldLocalAula = new javax.swing.JTextField();
        BotaoAddInterrup = new javax.swing.JButton();
        JanelaEliminarTarefa = new javax.swing.JDialog();
        jLabel2 = new javax.swing.JLabel();
        ConfirmarEliminarTarefa = new javax.swing.JButton();
        CancelarEliminarTarefa = new javax.swing.JButton();
        JanelaEliminarCompromisso = new javax.swing.JDialog();
        jLabel3 = new javax.swing.JLabel();
        ConfirmarEliminarCompromisso = new javax.swing.JButton();
        CancelarEliminarCompromisso = new javax.swing.JButton();
        JanelaEliminarHorario = new javax.swing.JDialog();
        jLabel4 = new javax.swing.JLabel();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        JanelaContinuarComCompromisso = new javax.swing.JDialog();
        jLabel5 = new javax.swing.JLabel();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        labeltitulo = new javax.swing.JLabel();
        nome1 = new javax.swing.JLabel();
        nome2 = new javax.swing.JLabel();
        nome3 = new javax.swing.JLabel();
        nome4 = new javax.swing.JLabel();
        nome5 = new javax.swing.JLabel();
        BarraMenu = new javax.swing.JMenuBar();
        Calendario = new javax.swing.JMenu();
        VisualizarCalendario = new javax.swing.JMenuItem();
        PreencheHorario = new javax.swing.JMenuItem();
        EliminarHorario = new javax.swing.JMenuItem();
        Tarefas = new javax.swing.JMenu();
        VisualizarTarefas = new javax.swing.JMenuItem();
        AddTarefas = new javax.swing.JMenuItem();

        JanelaCompromissos.setAlwaysOnTop(true);
        JanelaCompromissos.setResizable(false);

        Calendario1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                Calendario1PropertyChange(evt);
            }
        });

        LabelCompromissos.setText("Compromissos");

        BotaoAddCompromisso.setText("Adicionar Compromisso");
        BotaoAddCompromisso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoAddCompromissoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JanelaCompromissosLayout = new javax.swing.GroupLayout(JanelaCompromissos.getContentPane());
        JanelaCompromissos.getContentPane().setLayout(JanelaCompromissosLayout);
        JanelaCompromissosLayout.setHorizontalGroup(
            JanelaCompromissosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaCompromissosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JanelaCompromissosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Calendario1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(JanelaCompromissosLayout.createSequentialGroup()
                        .addComponent(LabelCompromissos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 236, Short.MAX_VALUE)
                        .addComponent(BotaoAddCompromisso, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        JanelaCompromissosLayout.setVerticalGroup(
            JanelaCompromissosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaCompromissosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Calendario1, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(JanelaCompromissosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(JanelaCompromissosLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(LabelCompromissos))
                    .addGroup(JanelaCompromissosLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(BotaoAddCompromisso)))
                .addContainerGap(232, Short.MAX_VALUE))
        );

        FormCompromisso.setResizable(false);

        jLabel7.setText("Novo Compromisso");

        LabelHoraInicio.setText("Hora Início");

        LabelHoraFim.setText("Hora Fim");

        LabelLocal.setText("Local");

        LabelCompromisso.setText("Compromisso");

        jButton2.setText("Adicionar Compromisso");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jScrollPane8.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane8.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaHIcompromisso.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaHIcompromisso.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane8.setViewportView(ListaHIcompromisso);

        jScrollPane9.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane9.setToolTipText("");
        jScrollPane9.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaHFcompromisso.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaHFcompromisso.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane9.setViewportView(ListaHFcompromisso);

        jLabel32.setText("h");

        jLabel33.setText("h");

        jScrollPane10.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane10.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaMIcompromisso.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaMIcompromisso.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane10.setViewportView(ListaMIcompromisso);

        jLabel34.setText("m");

        jLabel35.setText("m");

        jScrollPane11.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane11.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaMFCompromisso.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaMFCompromisso.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane11.setViewportView(ListaMFCompromisso);

        TextAreaCompromisso.setColumns(20);
        TextAreaCompromisso.setRows(5);
        jScrollPane12.setViewportView(TextAreaCompromisso);

        javax.swing.GroupLayout FormCompromissoLayout = new javax.swing.GroupLayout(FormCompromisso.getContentPane());
        FormCompromisso.getContentPane().setLayout(FormCompromissoLayout);
        FormCompromissoLayout.setHorizontalGroup(
            FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FormCompromissoLayout.createSequentialGroup()
                .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(FormCompromissoLayout.createSequentialGroup()
                        .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(FormCompromissoLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel7))
                            .addGroup(FormCompromissoLayout.createSequentialGroup()
                                .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(FormCompromissoLayout.createSequentialGroup()
                                        .addGap(50, 50, 50)
                                        .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(LabelLocal)
                                            .addComponent(LabelCompromisso)
                                            .addComponent(LabelHoraFim))
                                        .addGap(41, 41, 41))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, FormCompromissoLayout.createSequentialGroup()
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(LabelHoraInicio)
                                        .addGap(53, 53, 53)))
                                .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(TextFieldLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(FormCompromissoLayout.createSequentialGroup()
                                        .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel33, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(FormCompromissoLayout.createSequentialGroup()
                                                .addGap(1, 1, 1)
                                                .addComponent(jLabel32, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(31, 31, 31)
                                        .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(FormCompromissoLayout.createSequentialGroup()
                                                .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jLabel35))
                                            .addGroup(FormCompromissoLayout.createSequentialGroup()
                                                .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jLabel34)))))))
                        .addGap(0, 22, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, FormCompromissoLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton2)))
                .addContainerGap())
            .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(FormCompromissoLayout.createSequentialGroup()
                    .addGap(157, 157, 157)
                    .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(33, Short.MAX_VALUE)))
        );
        FormCompromissoLayout.setVerticalGroup(
            FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FormCompromissoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(FormCompromissoLayout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(LabelHoraFim)
                        .addGap(20, 20, 20)
                        .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(LabelLocal)
                            .addComponent(TextFieldLocal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(21, 21, 21)
                        .addComponent(LabelCompromisso)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
                        .addComponent(jButton2)
                        .addContainerGap())
                    .addGroup(FormCompromissoLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(FormCompromissoLayout.createSequentialGroup()
                                .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel35)
                                    .addComponent(jLabel33))
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel34)
                            .addComponent(jLabel32)
                            .addGroup(FormCompromissoLayout.createSequentialGroup()
                                .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(LabelHoraInicio)
                                    .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
            .addGroup(FormCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(FormCompromissoLayout.createSequentialGroup()
                    .addGap(156, 156, 156)
                    .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(74, Short.MAX_VALUE)))
        );

        JanelaVisualizacaoTarefas.setResizable(false);

        LabelTarefas.setText("Tarefas");

        javax.swing.GroupLayout JanelaVisualizacaoTarefasLayout = new javax.swing.GroupLayout(JanelaVisualizacaoTarefas.getContentPane());
        JanelaVisualizacaoTarefas.getContentPane().setLayout(JanelaVisualizacaoTarefasLayout);
        JanelaVisualizacaoTarefasLayout.setHorizontalGroup(
            JanelaVisualizacaoTarefasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(LabelTarefas, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
        );
        JanelaVisualizacaoTarefasLayout.setVerticalGroup(
            JanelaVisualizacaoTarefasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaVisualizacaoTarefasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelTarefas)
                .addContainerGap(375, Short.MAX_VALUE))
        );

        JanelaAddTarefas.setResizable(false);

        jLabel6.setText("Nova tarefa");

        jLabel15.setText("Tarefa");

        BotaoAddTarefa.setText("Adicionar Tarefa");
        BotaoAddTarefa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoAddTarefaActionPerformed(evt);
            }
        });

        TextAreaTarefa.setColumns(20);
        TextAreaTarefa.setRows(5);
        jScrollPane1.setViewportView(TextAreaTarefa);

        javax.swing.GroupLayout JanelaAddTarefasLayout = new javax.swing.GroupLayout(JanelaAddTarefas.getContentPane());
        JanelaAddTarefas.getContentPane().setLayout(JanelaAddTarefasLayout);
        JanelaAddTarefasLayout.setHorizontalGroup(
            JanelaAddTarefasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaAddTarefasLayout.createSequentialGroup()
                .addGroup(JanelaAddTarefasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(JanelaAddTarefasLayout.createSequentialGroup()
                        .addGroup(JanelaAddTarefasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(JanelaAddTarefasLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel6))
                            .addGroup(JanelaAddTarefasLayout.createSequentialGroup()
                                .addGap(36, 36, 36)
                                .addComponent(jLabel15)))
                        .addGap(0, 322, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, JanelaAddTarefasLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(BotaoAddTarefa)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, JanelaAddTarefasLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30))
        );
        JanelaAddTarefasLayout.setVerticalGroup(
            JanelaAddTarefasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaAddTarefasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addGap(32, 32, 32)
                .addComponent(jLabel15)
                .addGap(4, 4, 4)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                .addGap(38, 38, 38)
                .addComponent(BotaoAddTarefa)
                .addContainerGap())
        );

        JanelaPreenchHorario.setResizable(false);

        LabelHorario.setText("Horário escolar");

        LabelInicioSemestre.setText("Data de início do semestre");

        LabelFimSemestre.setText("Data de fim do semestre");

        DateChooserInicioSem.setDoubleBuffered(false);
        DateChooserInicioSem.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                DateChooserInicioSemPropertyChange(evt);
            }
        });

        DateChooserFimSem.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                DateChooserFimSemPropertyChange(evt);
            }
        });

        BotaoContinuarPreench.setText("Continuar com o preenchimento do horário");
        BotaoContinuarPreench.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoContinuarPreenchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JanelaPreenchHorarioLayout = new javax.swing.GroupLayout(JanelaPreenchHorario.getContentPane());
        JanelaPreenchHorario.getContentPane().setLayout(JanelaPreenchHorarioLayout);
        JanelaPreenchHorarioLayout.setHorizontalGroup(
            JanelaPreenchHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaPreenchHorarioLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JanelaPreenchHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, JanelaPreenchHorarioLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(BotaoContinuarPreench))
                    .addGroup(JanelaPreenchHorarioLayout.createSequentialGroup()
                        .addGroup(JanelaPreenchHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LabelHorario)
                            .addGroup(JanelaPreenchHorarioLayout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addGroup(JanelaPreenchHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(LabelInicioSemestre)
                                    .addComponent(LabelFimSemestre))
                                .addGap(56, 56, 56)
                                .addGroup(JanelaPreenchHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(DateChooserInicioSem, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE)
                                    .addComponent(DateChooserFimSem, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addGap(0, 34, Short.MAX_VALUE)))
                .addContainerGap())
        );
        JanelaPreenchHorarioLayout.setVerticalGroup(
            JanelaPreenchHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaPreenchHorarioLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelHorario)
                .addGap(42, 42, 42)
                .addGroup(JanelaPreenchHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LabelInicioSemestre)
                    .addComponent(DateChooserInicioSem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(JanelaPreenchHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LabelFimSemestre)
                    .addComponent(DateChooserFimSem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, Short.MAX_VALUE)
                .addComponent(BotaoContinuarPreench)
                .addContainerGap())
        );

        JanelaInterrupcoes.setResizable(false);

        LabelInicioInt.setText("Interrupções");

        LabelInicioInterrupcao.setText("Data de início da interrupção");

        LabelFimInterrupcao.setText("Data de fim da interrupção");

        DateChooserFimSem2.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                DateChooserFimSem2PropertyChange(evt);
            }
        });

        jDateChooser4.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jDateChooser4PropertyChange(evt);
            }
        });

        BotaoContinuaPreench2.setText("Continuar com o preenchimento do horário");
        BotaoContinuaPreench2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoContinuaPreench2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JanelaInterrupcoesLayout = new javax.swing.GroupLayout(JanelaInterrupcoes.getContentPane());
        JanelaInterrupcoes.getContentPane().setLayout(JanelaInterrupcoesLayout);
        JanelaInterrupcoesLayout.setHorizontalGroup(
            JanelaInterrupcoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaInterrupcoesLayout.createSequentialGroup()
                .addGroup(JanelaInterrupcoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(JanelaInterrupcoesLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LabelInicioInt)
                        .addGap(0, 315, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, JanelaInterrupcoesLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(BotaoContinuaPreench2))
                    .addGroup(JanelaInterrupcoesLayout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addGroup(JanelaInterrupcoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(LabelInicioInterrupcao)
                            .addComponent(LabelFimInterrupcao))
                        .addGap(56, 56, 56)
                        .addGroup(JanelaInterrupcoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jDateChooser4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(DateChooserFimSem2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        JanelaInterrupcoesLayout.setVerticalGroup(
            JanelaInterrupcoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaInterrupcoesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelInicioInt)
                .addGap(30, 30, 30)
                .addGroup(JanelaInterrupcoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LabelInicioInterrupcao)
                    .addComponent(jDateChooser4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(JanelaInterrupcoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LabelFimInterrupcao)
                    .addComponent(DateChooserFimSem2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 153, Short.MAX_VALUE)
                .addComponent(BotaoContinuaPreench2)
                .addContainerGap())
        );

        FormularioAula.setResizable(false);

        LabelAula.setText("Aula");

        LabelDiaSemana.setText("Dia da semana");

        LabelNomeAula.setText("Disciplina");

        TextFieldNomeAula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TextFieldNomeAulaActionPerformed(evt);
            }
        });

        LabelTipo.setText("Tipo");

        LabelInicioAula.setText("Hora de início");

        jScrollPane3.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaHoraInicio.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaHoraInicio.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane3.setViewportView(ListaHoraInicio);

        jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane4.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaMinutosInicio.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "00", "30" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaMinutosInicio.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane4.setViewportView(ListaMinutosInicio);

        LabelFimAula.setText("Hora de fim");

        BotaoAddAula.setText("Adicionar aula");
        BotaoAddAula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoAddAulaActionPerformed(evt);
            }
        });

        jScrollPane7.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane7.setToolTipText("");
        jScrollPane7.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaHoraFim.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaHoraFim.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane7.setViewportView(ListaHoraFim);

        LabelH.setText("h");

        LabelH2.setText("h");

        LabelM.setText("m");

        jScrollPane5.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane5.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaMinutosFim.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "00", "30" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaMinutosFim.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane5.setViewportView(ListaMinutosFim);

        LabelM2.setText("m");

        jScrollPane6.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane6.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaTipoAula.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Teórica", "Teórico-Prática", "Prática" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaTipoAula.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane6.setViewportView(ListaTipoAula);

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        ListaDias.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListaDias.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(ListaDias);

        jLabel1.setText("Local");

        BotaoAddInterrup.setText("Adicionar interrupção");
        BotaoAddInterrup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoAddInterrupActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout FormularioAulaLayout = new javax.swing.GroupLayout(FormularioAula.getContentPane());
        FormularioAula.getContentPane().setLayout(FormularioAulaLayout);
        FormularioAulaLayout.setHorizontalGroup(
            FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FormularioAulaLayout.createSequentialGroup()
                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(FormularioAulaLayout.createSequentialGroup()
                        .addComponent(BotaoAddInterrup)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 82, Short.MAX_VALUE)
                        .addComponent(BotaoAddAula))
                    .addGroup(FormularioAulaLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(FormularioAulaLayout.createSequentialGroup()
                                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(LabelInicioAula)
                                    .addComponent(LabelFimAula))
                                .addGap(64, 64, 64)
                                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(LabelH, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(FormularioAulaLayout.createSequentialGroup()
                                        .addGap(1, 1, 1)
                                        .addComponent(LabelH2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(31, 31, 31)
                                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(FormularioAulaLayout.createSequentialGroup()
                                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(LabelM))
                                    .addGroup(FormularioAulaLayout.createSequentialGroup()
                                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(LabelM2))))
                            .addGroup(FormularioAulaLayout.createSequentialGroup()
                                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(LabelDiaSemana)
                                    .addComponent(LabelNomeAula))
                                .addGap(58, 58, 58)
                                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(TextFieldNomeAula, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(LabelAula)
                            .addGroup(FormularioAulaLayout.createSequentialGroup()
                                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(LabelTipo)
                                    .addComponent(jLabel1))
                                .addGap(104, 104, 104)
                                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(TextFieldLocalAula, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap())
        );
        FormularioAulaLayout.setVerticalGroup(
            FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FormularioAulaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelAula)
                .addGap(26, 26, 26)
                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelDiaSemana))
                .addGap(18, 18, 18)
                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TextFieldNomeAula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelNomeAula))
                .addGap(13, 13, 13)
                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelTipo))
                .addGap(26, 26, 26)
                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(TextFieldLocalAula, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(FormularioAulaLayout.createSequentialGroup()
                        .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(LabelInicioAula)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(LabelFimAula)))
                    .addGroup(FormularioAulaLayout.createSequentialGroup()
                        .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(LabelM)
                            .addComponent(LabelH))
                        .addGap(43, 43, 43))
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelM2)
                    .addComponent(LabelH2))
                .addGap(18, 18, 18)
                .addGroup(FormularioAulaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BotaoAddInterrup)
                    .addComponent(BotaoAddAula))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        JanelaEliminarTarefa.setResizable(false);

        jLabel2.setText("Deseja mesmo Eliminar a tarefa?");

        ConfirmarEliminarTarefa.setText("Sim");
        ConfirmarEliminarTarefa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConfirmarEliminarTarefaActionPerformed(evt);
            }
        });

        CancelarEliminarTarefa.setText("Não");
        CancelarEliminarTarefa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelarEliminarTarefaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JanelaEliminarTarefaLayout = new javax.swing.GroupLayout(JanelaEliminarTarefa.getContentPane());
        JanelaEliminarTarefa.getContentPane().setLayout(JanelaEliminarTarefaLayout);
        JanelaEliminarTarefaLayout.setHorizontalGroup(
            JanelaEliminarTarefaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaEliminarTarefaLayout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addGroup(JanelaEliminarTarefaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(JanelaEliminarTarefaLayout.createSequentialGroup()
                        .addComponent(ConfirmarEliminarTarefa)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(CancelarEliminarTarefa))
                    .addComponent(jLabel2))
                .addContainerGap(56, Short.MAX_VALUE))
        );
        JanelaEliminarTarefaLayout.setVerticalGroup(
            JanelaEliminarTarefaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaEliminarTarefaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(27, 27, 27)
                .addGroup(JanelaEliminarTarefaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ConfirmarEliminarTarefa)
                    .addComponent(CancelarEliminarTarefa))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        JanelaEliminarCompromisso.setResizable(false);

        jLabel3.setText("Deseja mesmo eliminar o compromisso?");

        ConfirmarEliminarCompromisso.setText("Sim");
        ConfirmarEliminarCompromisso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConfirmarEliminarCompromissoActionPerformed(evt);
            }
        });

        CancelarEliminarCompromisso.setText("Não");
        CancelarEliminarCompromisso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelarEliminarCompromissoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JanelaEliminarCompromissoLayout = new javax.swing.GroupLayout(JanelaEliminarCompromisso.getContentPane());
        JanelaEliminarCompromisso.getContentPane().setLayout(JanelaEliminarCompromissoLayout);
        JanelaEliminarCompromissoLayout.setHorizontalGroup(
            JanelaEliminarCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaEliminarCompromissoLayout.createSequentialGroup()
                .addGroup(JanelaEliminarCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(JanelaEliminarCompromissoLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(ConfirmarEliminarCompromisso)
                        .addGap(59, 59, 59)
                        .addComponent(CancelarEliminarCompromisso))
                    .addGroup(JanelaEliminarCompromissoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3)))
                .addContainerGap(104, Short.MAX_VALUE))
        );
        JanelaEliminarCompromissoLayout.setVerticalGroup(
            JanelaEliminarCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaEliminarCompromissoLayout.createSequentialGroup()
                .addContainerGap(96, Short.MAX_VALUE)
                .addComponent(jLabel3)
                .addGap(26, 26, 26)
                .addGroup(JanelaEliminarCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CancelarEliminarCompromisso)
                    .addComponent(ConfirmarEliminarCompromisso))
                .addGap(41, 41, 41))
        );

        jLabel4.setText("Deseja mesmo Eliminar o Horario?");

        jButton6.setText("Sim");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setText("Não");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JanelaEliminarHorarioLayout = new javax.swing.GroupLayout(JanelaEliminarHorario.getContentPane());
        JanelaEliminarHorario.getContentPane().setLayout(JanelaEliminarHorarioLayout);
        JanelaEliminarHorarioLayout.setHorizontalGroup(
            JanelaEliminarHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaEliminarHorarioLayout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addGroup(JanelaEliminarHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(JanelaEliminarHorarioLayout.createSequentialGroup()
                        .addComponent(jButton6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton7))
                    .addComponent(jLabel4))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        JanelaEliminarHorarioLayout.setVerticalGroup(
            JanelaEliminarHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaEliminarHorarioLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addGap(27, 27, 27)
                .addGroup(JanelaEliminarHorarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton6)
                    .addComponent(jButton7))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        jLabel5.setText("Deseja mesmo adicionar o compromisso sem ter o horário preenchido?");

        jButton8.setText("Sim");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setText("Não");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JanelaContinuarComCompromissoLayout = new javax.swing.GroupLayout(JanelaContinuarComCompromisso.getContentPane());
        JanelaContinuarComCompromisso.getContentPane().setLayout(JanelaContinuarComCompromissoLayout);
        JanelaContinuarComCompromissoLayout.setHorizontalGroup(
            JanelaContinuarComCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaContinuarComCompromissoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(JanelaContinuarComCompromissoLayout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addComponent(jButton8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton9)
                .addGap(74, 74, 74))
        );
        JanelaContinuarComCompromissoLayout.setVerticalGroup(
            JanelaContinuarComCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JanelaContinuarComCompromissoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(27, 27, 27)
                .addGroup(JanelaContinuarComCompromissoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton8)
                    .addComponent(jButton9))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        labeltitulo.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        labeltitulo.setText("e-Planner");

        nome1.setText("André Gonçalves");

        nome2.setText("Inês Antunes");

        nome3.setText("Rita Maia");

        nome4.setText("Mário Rodrigues");

        nome5.setText("Tânia Ferreira");

        Calendario.setText("Calendário");

        VisualizarCalendario.setText("Visualizar calendário");
        VisualizarCalendario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                VisualizarCalendarioActionPerformed(evt);
            }
        });
        Calendario.add(VisualizarCalendario);

        PreencheHorario.setText("Preencher horário escolar");
        PreencheHorario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PreencheHorarioActionPerformed(evt);
            }
        });
        Calendario.add(PreencheHorario);

        EliminarHorario.setText("Eliminar horário escolar");
        EliminarHorario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EliminarHorarioActionPerformed(evt);
            }
        });
        Calendario.add(EliminarHorario);

        BarraMenu.add(Calendario);

        Tarefas.setText("Tarefas");

        VisualizarTarefas.setText("Visualizar tarefas existentes");
        VisualizarTarefas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                VisualizarTarefasActionPerformed(evt);
            }
        });
        Tarefas.add(VisualizarTarefas);

        AddTarefas.setText("Adicionar nova tarefa");
        AddTarefas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddTarefasActionPerformed(evt);
            }
        });
        Tarefas.add(AddTarefas);

        BarraMenu.add(Tarefas);

        setJMenuBar(BarraMenu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labeltitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(nome1)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(nome4)
                            .addGap(33, 33, 33)
                            .addComponent(nome5))))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(nome3)
                    .addComponent(nome2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(labeltitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nome1)
                    .addComponent(nome2))
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nome3)
                    .addComponent(nome4)
                    .addComponent(nome5))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    private void LeTarefas(){                                    //ler tarefas!!
       Scanner tar= new Scanner(System.in);
       boolean deteta=(new File("tarefas.xml")).exists();
       String a;
       if(deteta){
       Document doc= JdomFunctions.lerDocumentoXML("tarefas.xml");
       String exp1="//Tarefas/tarefa/nome";
        List resultados = TestexPath.pesquisaXPath(doc, exp1);
        // TestexPath.listaTodosElementos(resultados);
         for(int i=0;i<resultados.size();i++){
            TestexPath.listaUmElemento((Element) resultados.get(i));
         }
         
         try{
         //arrayTarefas = new ArrayList<tarefas>();
            for(int i=0;i<resultados.size();i++)
            {
                a=TestexPath.listaUmElemento((Element) resultados.get(i));
                arrayTarefas.add(new tarefas(a));
            }
         }catch(Exception e){System.err.println(e);}
   }
        
       else
           System.out.println("FICHEIRO NAO ENCONTRADO!!!");
   }
    
    private void LeCompromissos() throws ParseException{         
        Scanner tar= new Scanner(System.in);
        boolean deteta=(new File("compromissos.xml")).exists();
        if(deteta)
        {
            Document doc= JdomFunctions.lerDocumentoXML("compromissos.xml");
            // System.out.println("FICHEIRO!!!");
            String exp1="//compromissos/compromisso/comp";
            String exp2="//compromissos/compromisso/local";
            String exp3="//compromissos/compromisso/horaInicio";
            String exp4="//compromissos/compromisso/horaFim";
            String exp5="//compromissos/compromisso/data";
            
            List resultados = TestexPath.pesquisaXPath(doc, exp1);
            List resultados1 = TestexPath.pesquisaXPath(doc, exp2);
            List resultados2 = TestexPath.pesquisaXPath(doc, exp3);
            List resultados3 = TestexPath.pesquisaXPath(doc, exp4);
            List resultados4 = TestexPath.pesquisaXPath(doc, exp5);
            
            TestexPath.listaTodosElementos(resultados);
            
            String n;
            String l;
            String hi;
            String hf;
            String d;
            
            for(int i=0;i<resultados.size();i++)
            {
                n=TestexPath.listaUmElemento((Element) resultados.get(i));
                l=TestexPath.listaUmElemento((Element) resultados1.get(i));
                hi=TestexPath.listaUmElemento((Element) resultados2.get(i));
                hf=TestexPath.listaUmElemento((Element) resultados3.get(i));
                d=TestexPath.listaUmElemento((Element) resultados4.get(i));
                
                if(funcoes.ValidaHora(hi)==0 && funcoes.ValidaHora(hf)==0 && funcoes.ValidaData(d)==0)
                {
                    compromissos novo = new compromissos(n,l,hi,hf,d);
                    arrayCompromissos.add(novo);
                }                
            }
       }
   }   
   
    private void LeHorario() throws ParseException{ 
       Scanner hor= new Scanner(System.in);
       boolean deteta=(new File("horario.xml")).exists();
       String AS;
       String AT;
       String AQ;
       String AQI;
       String ASE;
       String ASA;
       
       String TIAS;
       String TIAT;
       String TIAQ;
       String TIQI;
       String TISE;
       String TISA;
       
       String LAS;
       String LAT;
       String LAQ;
       String LAQI;
       String LASE;
       String LASA;
       
       String HIAS;
       String HIAT;
       String HIAQ;
       String HIQI;
       String HISE;
       String HISA;
       
       String HFAS;
       String HFAT;
       String HFAQ;
       String HFQI;
       String HFSE;
       String HFSA;
       
       String DF="";
       String DI="";
       
       String DII;
       String DIF;
       
       
       if(deteta)
       {
            Document doc= JdomFunctions.lerDocumentoXML("horario.xml");
            // System.out.println("FICHEIRO!!!");
            String AulasSegunda ="//horario/diaSemana[@dia='Segunda']/aulas/aula/cadeira";
            String AulasTerca ="//horario/diaSemana[@dia='Terca']/aulas/aula/cadeira";
            String AulasQuarta ="//horario/diaSemana[@dia='Quarta']/aulas/aula/cadeira";
            String AulasQuinta ="//horario/diaSemana[@dia='Quinta']/aulas/aula/cadeira";
            String AulasSexta ="//horario/diaSemana[@dia='Sexta']/aulas/aula/cadeira";
            String AulasSabado ="//horario/diaSemana[@dia='Sabado']/aulas/aula/cadeira";
            //TIPOS AULA        
            String TipoAulasSegunda ="//horario/diaSemana[@dia='Segunda']/aulas/aula/tipoAula";
            String TipoAulasTerca ="//horario/diaSemana[@dia='Terca']/aulas/aula/tipoAula";
            String TipoAulasQuarta ="//horario/diaSemana[@dia='Quarta']/aulas/aula/tipoAula";
            String TipoAulasQuinta ="//horario/diaSemana[@dia='Quinta']/aulas/aula/tipoAula";
            String TipoAulasSexta ="//horario/diaSemana[@dia='Sexta']/aulas/aula/tipoAula";
            String TipoAulasSabado ="//horario/diaSemana[@dia='Sabado']/aulas/aula/tipoAula";        
            //LOCAL       
            String LocalAulasSegunda ="//horario/diaSemana[@dia='Segunda']/aulas/aula/local";
            String LocalAulasTerca ="//horario/diaSemana[@dia='Terca']/aulas/aula/local";
            String LocalAulasQuarta ="//horario/diaSemana[@dia='Quarta']/aulas/aula/local";
            String LocalAulasQuinta ="//horario/diaSemana[@dia='Quinta']/aulas/aula/local";
            String LocalAulasSexta ="//horario/diaSemana[@dia='Sexta']/aulas/aula/local";
            String LocalAulasSabado ="//horario/diaSemana[@dia='Sabado']/aulas/aula/local";
        
        
            String Dinicio = "//horario/dataInicio";
            String Dfim = "//horario/dataFim";
            
        
            String HIAulasSegunda ="//horario/diaSemana[@dia='Segunda']/aulas/aula/horaInicio";
            String HIAulasTerca ="//horario/diaSemana[@dia='Terca']/aulas/aula/horaInicio";
            String HIAulasQuarta ="//horario/diaSemana[@dia='Quarta']/aulas/aula/horaInicio";
            String HIAulasQuinta ="//horario/diaSemana[@dia='Quinta']/aulas/aula/horaInicio";
            String HIAulasSexta ="//horario/diaSemana[@dia='Sexta']/aulas/aula/horaInicio";
            String HIAulasSabado ="//horario/diaSemana[@dia='Sabado']/aulas/aula/horaInicio";
        
            String HFAulasSegunda ="//horario/diaSemana[@dia='Segunda']/aulas/aula/horaFim";
            String HFAulasTerca ="//horario/diaSemana[@dia='Terca']/aulas/aula/horaFim";
            String HFAulasQuarta ="//horario/diaSemana[@dia='Quarta']/aulas/aula/horaFim";
            String HFAulasQuinta ="//horario/diaSemana[@dia='Quinta']/aulas/aula/horaFim";
            String HFAulasSexta ="//horario/diaSemana[@dia='Sexta']/aulas/aula/horaFim";
            String HFAulasSabado ="//horario/diaSemana[@dia='Sabado']/aulas/aula/horaFim";
        
            String pesquisaDII="//horario/interrupcoes/interrupcao/dataInicioInt";
            String pesquisaDIF="//horario/interrupcoes/interrupcao/dataFimInt";
        
            List rDII=TestexPath.pesquisaXPath(doc, pesquisaDII);
            List rDIF=TestexPath.pesquisaXPath(doc, pesquisaDIF);
             
             
             
            List AulasS = TestexPath.pesquisaXPath(doc, AulasSegunda);
            List AulasT = TestexPath.pesquisaXPath(doc, AulasTerca);
            List AulasQ = TestexPath.pesquisaXPath(doc, AulasQuarta);
            List AulasQi = TestexPath.pesquisaXPath(doc, AulasQuinta);
            List AulasSe = TestexPath.pesquisaXPath(doc, AulasSexta);
            List AulasSa = TestexPath.pesquisaXPath(doc, AulasSabado);
       
            List datainicio = TestexPath.pesquisaXPath(doc, Dinicio);
            List datafim = TestexPath.pesquisaXPath(doc, Dfim);
       
            List Tps = TestexPath.pesquisaXPath(doc, TipoAulasSegunda);
            List Tpt = TestexPath.pesquisaXPath(doc, TipoAulasTerca);
            List Tpq = TestexPath.pesquisaXPath(doc, TipoAulasQuarta);
            List Tpqi = TestexPath.pesquisaXPath(doc, TipoAulasQuinta);
            List Tpse = TestexPath.pesquisaXPath(doc, TipoAulasSexta);
            List Tpsa = TestexPath.pesquisaXPath(doc, TipoAulasSabado);
        
            List Locals = TestexPath.pesquisaXPath(doc, LocalAulasSegunda);
            List Localt = TestexPath.pesquisaXPath(doc, LocalAulasTerca);
            List Localq = TestexPath.pesquisaXPath(doc, LocalAulasQuarta);
            List Localqi = TestexPath.pesquisaXPath(doc, LocalAulasQuinta);
            List Localse = TestexPath.pesquisaXPath(doc, LocalAulasSexta);
            List Localsa = TestexPath.pesquisaXPath(doc, LocalAulasSabado);
       
       
            List HIs = TestexPath.pesquisaXPath(doc, HIAulasSegunda);
            List HIt = TestexPath.pesquisaXPath(doc, HIAulasTerca);
            List HIq = TestexPath.pesquisaXPath(doc, HIAulasQuarta);
            List HIqi = TestexPath.pesquisaXPath(doc, HIAulasQuinta);
            List HIse = TestexPath.pesquisaXPath(doc, HIAulasSexta);
            List HIsa = TestexPath.pesquisaXPath(doc, HIAulasSabado);
       
       
            List HFs = TestexPath.pesquisaXPath(doc, HFAulasSegunda);
            List HFt = TestexPath.pesquisaXPath(doc, HFAulasTerca);
            List HFq = TestexPath.pesquisaXPath(doc, HFAulasQuarta);
            List HFqi = TestexPath.pesquisaXPath(doc, HFAulasQuinta);
            List HFse = TestexPath.pesquisaXPath(doc, HFAulasSexta);
            List HFsa = TestexPath.pesquisaXPath(doc, HFAulasSabado);
            
            for(int i=0;i<datainicio.size();i++)
            {
                DI=TestexPath.listaUmElemento((Element) datainicio.get(i));
                DF=TestexPath.listaUmElemento((Element) datafim.get(i));
            }
            
            if(funcoes.ValidaData(DI)==0 && funcoes.ValidaData(DF)==0)
            {
                arrayHorario=new horario(DI,DF);            
                newFlagHorario=1;
                for(int i=0;i<rDII.size();i++)
                {

                   DII= TestexPath.listaUmElemento((Element) rDII.get(i));
                   DIF= TestexPath.listaUmElemento((Element) rDIF.get(i));
                  
                  if(funcoes.ValidaData(DII)==0 && funcoes.ValidaData(DIF)==0)
                   {    
                        interrupcoes in=new interrupcoes(DII,DIF);
                        arrayHorario.addInterrupcao(in);
                   }
                }
             
                for(int i=0;i<AulasS.size();i++)
                {
                    AS=TestexPath.listaUmElemento((Element) AulasS.get(i));
                    TIAS=TestexPath.listaUmElemento((Element) Tps.get(i));
                    LAS=TestexPath.listaUmElemento((Element) Locals.get(i));
                    HIAS=TestexPath.listaUmElemento((Element) HIs.get(i)); 
                    HFAS=TestexPath.listaUmElemento((Element) HFs.get(i)); 

                    if(funcoes.ValidaHora(HIAS)==0 && funcoes.ValidaHora(HFAS)==0)
                    {
                        arrayHorario.addAulaSegunda(new aula(AS, TIAS, LAS, HIAS, HFAS));
                    }
                }
        
                for(int i=0;i<AulasT.size();i++)
                {
                    AT=TestexPath.listaUmElemento((Element) AulasT.get(i));
                    TIAT=TestexPath.listaUmElemento((Element) Tpt.get(i));
                    LAT=TestexPath.listaUmElemento((Element) Localt.get(i));
                    HIAT=TestexPath.listaUmElemento((Element) HIt.get(i)); 
                    HFAT=TestexPath.listaUmElemento((Element) HFt.get(i)); 

                    if(funcoes.ValidaHora(HIAT)==0 && funcoes.ValidaHora(HFAT)==0)
                    {
                        arrayHorario.addAulaTerca(new aula(AT, TIAT, LAT, HIAT, HFAT));
                    }

                }
          
                for(int i=0;i<AulasQ.size();i++)
                {
                    AQ=TestexPath.listaUmElemento((Element) AulasQ.get(i));
                    TIAQ=TestexPath.listaUmElemento((Element) Tpq.get(i));
                    LAQ=TestexPath.listaUmElemento((Element) Localq.get(i));
                    HIAQ=TestexPath.listaUmElemento((Element) HIq.get(i)); 
                    HFAQ=TestexPath.listaUmElemento((Element) HFq.get(i)); 

                    if(funcoes.ValidaHora(HIAQ)==0 && funcoes.ValidaHora(HFAQ)==0)
                    {
                        arrayHorario.addAulaQuarta(new aula(AQ, TIAQ, LAQ, HIAQ, HFAQ));
                    }
                }
            
                for(int i=0;i<AulasQi.size();i++)
                {
                    AQI=TestexPath.listaUmElemento((Element) AulasQi.get(i));
                    TIQI=TestexPath.listaUmElemento((Element) Tpqi.get(i));  
                    LAQI=TestexPath.listaUmElemento((Element) Localqi.get(i));
                    HIQI=TestexPath.listaUmElemento((Element) HIqi.get(i)); 
                    HFQI=TestexPath.listaUmElemento((Element) HFqi.get(i)); 

                    if(funcoes.ValidaHora(HIQI)==0 && funcoes.ValidaHora(HFQI)==0)
                    {
                        arrayHorario.addAulaQuinta(new aula(AQI, TIQI, LAQI, HIQI, HFQI));
                    }
                }
            
                for(int i=0;i<AulasSe.size();i++)
                {
                    ASE=TestexPath.listaUmElemento((Element) AulasSe.get(i));
                    TISE=TestexPath.listaUmElemento((Element) Tpse.get(i));
                    LASE=TestexPath.listaUmElemento((Element) Localse.get(i));
                    HISE=TestexPath.listaUmElemento((Element) HIse.get(i)); 
                    HFSE=TestexPath.listaUmElemento((Element) HFse.get(i)); 

                    if(funcoes.ValidaHora(HISE)==0 && funcoes.ValidaHora(HFSE)==0)
                    {
                        arrayHorario.addAulaSexta(new aula(ASE, TISE, LASE, HISE, HFSE));
                    }
                }
             
                for(int i=0;i<AulasSa.size();i++)
                {        
                    ASA=TestexPath.listaUmElemento((Element) AulasSa.get(i));
                    TISA=TestexPath.listaUmElemento((Element) Tpsa.get(i));
                    LASA=TestexPath.listaUmElemento((Element) Localsa.get(i));
                    HISA=TestexPath.listaUmElemento((Element) HIsa.get(i)); 
                    HFSA=TestexPath.listaUmElemento((Element) HFsa.get(i)); 

                    if(funcoes.ValidaHora(HISA)==0 && funcoes.ValidaHora(HFSA)==0)
                    {
                        arrayHorario.addAulaSabado(new aula(ASA, TISA, LASA, HISA, HFSA));
                    }
                 }

                 flagHorario=1;
                 System.out.println("Cheguei aqui");
            }
         }
       
         else
            System.out.println("FICHEIRO NAO ENCONTRADO!!!");
   }
   
    private void VisualizarTarefas(){
        labelsTarefas.clear();
        buttonsTarefas.clear();   
        panelTarefas.removeAll();
        
        int pos_x = 15, pos_y = 10;
        
        for (int i = 0; i < arrayTarefas.size(); i++) 
        {
            System.err.println("Ciclo for");            
            panelTarefas.setBounds(10, 25, 375, 340);
        
            JLabel nova = new JLabel(arrayTarefas.get(i).getTarefa());
            nova.setLocation(pos_x,pos_y);
            nova.setSize(330, 20);
            labelsTarefas.add(nova);
            
            BotaoAlt novo = new BotaoAlt(i, "Eliminar Tarefa");
            novo.setLocation(pos_x+225,pos_y+20);
            novo.setSize(125, 20);
            buttonsTarefas.add(novo);
                
            labelsTarefas.get(labelsTarefas.size()-1).setVisible(true);
            panelTarefas.add(labelsTarefas.get(labelsTarefas.size()-1));  
            
            buttonsTarefas.get(buttonsTarefas.size()-1).setVisible(true);
            
            buttonsTarefas.get(buttonsTarefas.size()-1).addActionListener
            (
                new ActionListener()
                {
                    public void actionPerformed(ActionEvent arg0)
                    {
                        BotaoAlt x = (BotaoAlt) arg0.getSource();
                        IndiceEliminarTarefa=x.get_indice();
                         JanelaEliminarTarefa.setLocationRelativeTo(null);
                        JanelaEliminarTarefa.setVisible(true);
                        JanelaEliminarTarefa.setSize(300,150);
                        JanelaVisualizacaoTarefas.setVisible(false);
                        panelTarefas.setVisible(false);
                        panelTarefas.removeAll();
                        panelTarefas.updateUI();
                        
                    }
                }
            );
            
            
            
            panelTarefas.add(buttonsTarefas.get(buttonsTarefas.size()-1));  
            
            panelTarefas.revalidate();
            panelTarefas.repaint();
                
            pos_x=pos_x;
            pos_y=pos_y+45;
        }
        
        panelTarefas.setVisible(true);
        JanelaVisualizacaoTarefas.add(panelTarefas);
        JanelaVisualizacaoTarefas.invalidate();
        JanelaVisualizacaoTarefas.repaint();
    }
    
    private Document gravaDadosHorario(){
        Element HorarioElemento = new Element("horario");
        Element DIElemento = new Element("dataInicio");
        DIElemento.addContent(arrayHorario.getDataInicio());
        Element DFElemento = new Element("dataFim");
        DFElemento.addContent(arrayHorario.getDataFim());
        Document novoDoc = new Document();
        Element diaSegunda = new Element("diaSemana");
        diaSegunda.setAttribute("dia","Segunda");
        Element Auls = new Element("aulas");
        Element diaTerca = new Element("diaSemana");
        diaTerca.setAttribute("dia","Terca");
        Element Aulst = new Element("aulas");
        Element diaQuarta = new Element("diaSemana");
        diaQuarta.setAttribute("dia","Quarta");
        Element Aulsq = new Element("aulas");
        Element diaQuinta = new Element("diaSemana");
        diaQuinta.setAttribute("dia","Quinta");
        Element Aulsqi = new Element("aulas");
        Element diaSexta = new Element("diaSemana");
        diaSexta.setAttribute("dia","Sexta");
        Element Aulse = new Element("aulas");
        Element diaSabado = new Element("diaSemana");
        diaSabado.setAttribute("dia","Sabado");
        Element Aulsa = new Element("aulas");
        Element ints=new Element ("interrupcoes");
        
        
        for(int i=0;i<arrayHorario.getInts();i++)
        {
            Element into=new Element ("interrupcao");
            adicionaInterrupcao(into,arrayHorario,i); 
            ints.addContent(into);
        }
        
        
        for(int i=0;i<arrayHorario.getNumAulasSegunda();i++)
        {
            adicionaSegunda(Auls,arrayHorario,i);
        }
        for(int i=0;i<arrayHorario.getNumAulasTerca();i++)
        {
            adicionaTerca(Aulst,arrayHorario,i);
        }
        
        for(int i=0;i<arrayHorario.getNumAulasQuarta();i++)
        {
            adicionaQuarta(Aulsq,arrayHorario,i);
        }
             
        for(int i=0;i<arrayHorario.getNumAulasQuinta();i++)
        {
            adicionaQuinta(Aulsqi,arrayHorario,i);
        }
            
        for(int i=0;i<arrayHorario.getNumAulasSexta();i++)
        {
            adicionaSexta(Aulse,arrayHorario,i);
        }
        
        for(int i=0;i<arrayHorario.getNumAulasSabado();i++)
        {
            adicionaSabado(Aulsa,arrayHorario,i);
        }
                      
        diaSegunda.addContent(Auls);
        diaTerca.addContent(Aulst);
        diaQuarta.addContent(Aulsq);
        diaQuinta.addContent(Aulsqi);
        diaSexta.addContent(Aulse);
        diaSexta.addContent(Aulsa);       
        
        HorarioElemento.addContent(DIElemento);
        HorarioElemento.addContent(DFElemento);
        HorarioElemento.addContent(diaSegunda);
        HorarioElemento.addContent(diaTerca);
        HorarioElemento.addContent(diaQuarta);
        HorarioElemento.addContent(diaQuinta);
        HorarioElemento.addContent(diaSexta);
        HorarioElemento.addContent(diaSabado);
        HorarioElemento.addContent(ints);
        novoDoc.addContent(HorarioElemento);

        return novoDoc;
    }
    
    private Element adicionaSegunda(Element Raiz,horario h,int i){
        Element Aul = new Element("aula");
      
        Element cadS=new Element("cadeira");
        cadS.addContent(h.getAulaSegunda(i));
        Element tpaS=new Element("tipoAula");
        tpaS.addContent(h.getTipoAulaSegunda(i));
        Element locS=new Element("local");
        locS.addContent(h.getLocalSegunda(i));
        Element hinS=new Element("horaInicio");
        hinS.addContent(h.getHoraInicioSegunda(i));
        Element hfimS=new Element("horaFim");
        hfimS.addContent(h.getHoraFimSegunda(i));
        Aul.addContent(cadS);
        Aul.addContent(tpaS);       
        Aul.addContent(locS);
        Aul.addContent(hinS);
        Aul.addContent(hfimS);
        Raiz.addContent(Aul);
        return Raiz;        
    }
     
    private Element adicionaInterrupcao(Element Raiz,horario h,int i){
        Element DII = new Element("dataInicioInt");
        Element DIF = new Element("dataFimInt");
        DII.addContent(h.getIntI(i));
        DIF.addContent(h.getIntF(i));
        Raiz.addContent(DII);
        Raiz.addContent(DIF);
        return Raiz;
    }
          
    private Element adicionaTerca(Element Raiz,horario h,int i){
        Element Aul = new Element("aula");
      
        Element cadT=new Element("cadeira");
        cadT.addContent(h.getAulaTerca(i));
        Element tpaT=new Element("tipoAula");
        tpaT.addContent(h.getTipoAulaTerca(i));
        Element locT=new Element("local");
        locT.addContent(h.getLocalTerca(i));
        Element hinT=new Element("horaInicio");
        hinT.addContent(h.getHoraInicioTerca(i));
        Element hfimT=new Element("horaFim");
        hfimT.addContent(h.getHoraFimTerca(i));
        Aul.addContent(cadT);
        Aul.addContent(tpaT);
        Aul.addContent(locT);
        Aul.addContent(hinT);
        Aul.addContent(hfimT);
        Raiz.addContent(Aul);
        return Raiz;        
    }
          
    private Element adicionaQuarta(Element Raiz,horario h,int i){
        Element Aul = new Element("aula");
        Element cadQ=new Element("cadeira");
        cadQ.addContent(h.getAulaQuarta(i));
      
        Element tpaQ=new Element("tipoAula");
        tpaQ.addContent(h.getTipoAulaQuarta(i));
        Element locQ=new Element("local");
        locQ.addContent(h.getLocalQuarta(i));
        Element hinQ=new Element("horaInicio");
        hinQ.addContent(h.getHoraInicioQuarta(i));
        Element hfimQ=new Element("horaFim");
        hfimQ.addContent(h.getHoraFimQuarta(i));
        Aul.addContent(cadQ);
        Aul.addContent(tpaQ);
        Aul.addContent(locQ);
        Aul.addContent(hinQ);
        Aul.addContent(hfimQ);
        Raiz.addContent(Aul);
        return Raiz;        
    }
      
    private Element adicionaQuinta(Element Raiz,horario h,int i){
        Element Aul = new Element("aula");     
        Element cadQI=new Element("cadeira");
        cadQI.addContent(h.getAulaQuinta(i));
        Element tpaQI=new Element("tipoAula");
        tpaQI.addContent(h.getTipoAulaQuinta(i));
        Element locQI=new Element("local");
        locQI.addContent(h.getLocalQuinta(i));
        Element hinQI=new Element("horaInicio");
        hinQI.addContent(h.getHoraInicioQuinta(i));
        Element hfimQI=new Element("horaFim");
        hfimQI.addContent(h.getHoraFimQuinta(i));
        Aul.addContent(cadQI);
        Aul.addContent(tpaQI);
        Aul.addContent(locQI);
        Aul.addContent(hinQI);
        Aul.addContent(hfimQI);
        Raiz.addContent(Aul);
        return Raiz;
    }
          
    private Element adicionaSexta(Element Raiz,horario h,int i){
        Element Aul = new Element("aula");      
        Element cadSe=new Element("cadeira");
        cadSe.addContent(h.getAulaSexta(i));
        Element tpaSE=new Element("tipoAula");
        tpaSE.addContent(h.getTipoAulaSexta(i));
        Element locSE=new Element("local");
        locSE.addContent(h.getLocalSexta(i));
        Element hinSE=new Element("horaInicio");
        hinSE.addContent(h.getHoraInicioSexta(i));
        Element hfimSE=new Element("horaFim");
        hfimSE.addContent(h.getHoraFimSexta(i));
        Aul.addContent(cadSe);
        Aul.addContent(tpaSE);
        Aul.addContent(locSE);
        Aul.addContent(hinSE);
        Aul.addContent(hfimSE);
        Raiz.addContent(Aul);
        return Raiz;        
    }
           
    private Element adicionaSabado(Element Raiz,horario h,int i){
        Element Aul = new Element("aula");
        Element cadSa=new Element("cadeira");
        cadSa.addContent(h.getAulaSabado(i));
        Element tpaSA=new Element("tipoAula");
        tpaSA.addContent(h.getTipoAulaSabado(i));
        Element locSA=new Element("local");
        locSA.addContent(h.getLocalSabado(i));
        Element hinSA=new Element("horaInicio");
        hinSA.addContent(h.getHoraInicioSabado(i));
        Element hfimSA=new Element("horaFim");
        hfimSA.addContent(h.getHoraFimSabado(i));
        Aul.addContent(cadSa);
        Aul.addContent(tpaSA);
        Aul.addContent(locSA);
        Aul.addContent(hinSA);
        Aul.addContent(hfimSA);
        Raiz.addContent(Aul);
        return Raiz;
    }
        
    private Document GravaDadosCompromissos(){
        Element CompromissosElemento = new Element("compromissos");  
        Document novoDoc = new Document();
        novoDoc.addContent(CompromissosElemento);    
      
        for(int i=0;i<arrayCompromissos.size();i++){
            adicionaCompromisso(CompromissosElemento,arrayCompromissos.get(i));
        }
        return novoDoc;
   }
    
   /*  private  Element adicionaHorario(Element Raiz,horario h){
       
       //   Element horarioElemento = new Element("horario");
           Element DIElemento = new Element("dataInicio");
           DIElemento.addContent(h.getDataInicio());
          Element DFElemento = new Element("dataFim");
                  DFElemento.addContent(h.getDataFim());
          Element DSS=new Element("diaSemana");
          DSS.setAttribute("dia","Segunda");
   
         Element tpaS=new Element("TipoAula");
        Element locS=new Element("local");
        Element hinS=new Element("horaInicio");
        Element hfimS=new Element("horaFim");
        
        Element ints=new Element("interrupcoes");
        Element inte=new Element("interrupcao");
        
        Element dii=new Element("dataInicioInt");
       

        Element dfi=new Element("dataFimInt");
        for(int j=0;j<h.getInts();j++){
            ints.addContent(inte);
            dii.addContent(h.getIntI(j));
            dfi.addContent(h.getIntF(j));
            inte.addContent(dii);
        }
        ints.addContent(inte);
          Element alsS=new Element("aulas");
          Element alS=new Element("aula");
          Element cadS=new Element("cadeira");
          
          
          for(int j=0;j<h.getNumAulasSegunda();j++){
           cadS.addContent(h.getAulaSegunda(j));
           tpaS.addContent(h.getTipoAulaSegunda(j));
           locS.addContent(h.getLocalSegunda(j));
           hinS.addContent(h.getHoraInicioSegunda(j));
           hfimS.addContent(h.getHoraFimSegunda(j));
            alS.addContent(cadS);
            alS.addContent(tpaS);
            alS.addContent(locS);
             alS.addContent(hinS);
            alS.addContent(hfimS);
          }
         
            alsS.addContent(alS);
          
      
        DSS.addContent(alsS);
        
       
        
        Raiz.addContent(DIElemento);
        Raiz.addContent(DFElemento);
        Raiz.addContent(DSS);
        Raiz.addContent(ints);
        return Raiz;
        
     }*/
     
   
    private static Element adicionaCompromisso( Element Raiz, compromissos t){
        Element compromissoElemento = new Element("compromisso");
        Element cElemento = new Element("comp"); 
        cElemento.addContent(t.getCompromisso());
        Element localElemento = new Element("local");
        localElemento.addContent(t.getLocal());
        Element dataElemento = new Element("data");
        dataElemento.addContent(t.getData());
        Element hinicioElemento = new Element("horaInicio");
        hinicioElemento.addContent(t.getHoraInicio());
        Element hfimElemento = new Element("horaFim");
        hfimElemento.addContent(t.getHoraFim());
            
        compromissoElemento.addContent(cElemento);
        compromissoElemento.addContent(localElemento);
        compromissoElemento.addContent(dataElemento);
        compromissoElemento.addContent(hinicioElemento);
        compromissoElemento.addContent(hfimElemento);
                  
        Raiz.addContent(compromissoElemento);
        return Raiz;
    }
    
    private Document GravaDadosTarefas(){
        Element TarefasElemento = new Element("Tarefas");  
        Document novoDoc = new Document();
        novoDoc.addContent(TarefasElemento);
      
        for(int i=0;i<arrayTarefas.size();i++){
            TarefasElemento= adicionaTarefa(TarefasElemento,arrayTarefas.get(i));
        }
        return novoDoc;
   }
      
    private static Element adicionaTarefa( Element Raiz, tarefas t){
        Element tarefaElemento = new Element("tarefa"); 
        Element nomeTarefa = new Element("nome");  
        
         nomeTarefa.addContent(t.getTarefa());
         tarefaElemento.addContent(nomeTarefa);
         
         Raiz.addContent(tarefaElemento);
         return Raiz;
     }
   
    private void VisualizarCompromissos(String data) throws ParseException{        
       DataAux=data;
       panelCompromissos.removeAll();
       int pos_x = 15, pos_y = 5;
       panelCompromissos.setBounds(10, 210, 475, 225);
       panelCompromissos.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
       panelCompromissos.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);  
       panelCompromissos.revalidate();
       panelCompromissos.setVisible(true);
       
       
       if(flagHorario==1)
       {         
           System.err.println(arrayHorario.getAulaSegunda(0));
           System.err.println("TESTE");
            if(DiaSemana.equals("Seg") && funcoes.VerificaDatasHorario(data, arrayHorario.getDataInicio(), arrayHorario.getDataFim())==0)
            {
                //System.err.println("TESTE 2");
                if(arrayHorario.getInts()>0)
                {
                for (int j=0;j<arrayHorario.getInts();j++)
                {
                    if(funcoes.VerificaDatasInterrupcoes(data, arrayHorario.getIntI(j), arrayHorario.getIntF(j))==1 && arrayHorario.getNumAulasSegunda()>0)
                    {
                        //System.err.println("TESTE 3");
                        for(int i=0;i<arrayHorario.getNumAulasSegunda();i++)
                        {
                            JLabel nova = new JLabel(arrayHorario.getAulaSegunda(i));
                            JLabel nova1 = new JLabel(arrayHorario.getTipoAulaSegunda(i)+"    "+arrayHorario.getLocalSegunda(i));
                            JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioSegunda(i)+" às "+arrayHorario.getHoraFimSegunda(i));
                            nova.setSize(275, 20);                
                            nova.setLocation(pos_x,pos_y);
                            labelsCompromissos.add(nova);

                            nova1.setSize(275, 20);                
                            nova1.setLocation(pos_x,pos_y+20);
                            nova2.setSize(275, 20);                
                            nova2.setLocation(pos_x,pos_y+40);

                            BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                            novo.setSize(165, 60);
                            novo.setLocation(pos_x+270,pos_y);
                            buttonsCompromissos.add(novo);

                            labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                            panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                            panelCompromissos.add(nova1);
                            panelCompromissos.add(nova2);

                            buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                            buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                            new ActionListener()
                            {
                                public void actionPerformed(ActionEvent arg0)
                                {
                                    BotaoAlt x = (BotaoAlt) arg0.getSource();
                                    IndiceEliminarCompromisso=x.get_indice();
                                    DataEliminarCompromisso=DataAux;
                                    JanelaEliminarCompromisso.setVisible(true);
                                    JanelaEliminarCompromisso.setSize(260,90);
                                    panelCompromissos.setVisible(false);
                                    panelCompromissos.removeAll();
                                    panelCompromissos.updateUI();                            
                                }
                            }
                            );

                            panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                            panelCompromissos.revalidate();
                            panelCompromissos.repaint();
                            pos_y=pos_y+60;
                        }
                    }
                    
                }}
                else
                {
                    for(int i=0;i<arrayHorario.getNumAulasSegunda();i++)
                        {
                            JLabel nova = new JLabel(arrayHorario.getAulaSegunda(i));
                            JLabel nova1 = new JLabel(arrayHorario.getTipoAulaSegunda(i)+"    "+arrayHorario.getLocalSegunda(i));
                            JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioSegunda(i)+" às "+arrayHorario.getHoraFimSegunda(i));
                            nova.setSize(275, 20);                
                            nova.setLocation(pos_x,pos_y);
                            labelsCompromissos.add(nova);

                            nova1.setSize(275, 20);                
                            nova1.setLocation(pos_x,pos_y+20);
                            nova2.setSize(275, 20);                
                            nova2.setLocation(pos_x,pos_y+40);

                            BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                            novo.setSize(165, 60);
                            novo.setLocation(pos_x+270,pos_y);
                            buttonsCompromissos.add(novo);

                            labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                            panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                            panelCompromissos.add(nova1);
                            panelCompromissos.add(nova2);

                            buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                            buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                            new ActionListener()
                            {
                                public void actionPerformed(ActionEvent arg0)
                                {
                                    BotaoAlt x = (BotaoAlt) arg0.getSource();
                                    IndiceEliminarCompromisso=x.get_indice();
                                    DataEliminarCompromisso=DataAux;
                                    JanelaEliminarCompromisso.setVisible(true);
                                    JanelaEliminarCompromisso.setSize(260,90);
                                    panelCompromissos.setVisible(false);
                                    panelCompromissos.removeAll();
                                    panelCompromissos.updateUI();                            
                                }
                            }
                            );

                            panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                            panelCompromissos.revalidate();
                            panelCompromissos.repaint();
                            pos_y=pos_y+60;
                        }
                }
           }
           
            if(DiaSemana.equals("Ter") && funcoes.VerificaDatasHorario(data, arrayHorario.getDataInicio(), arrayHorario.getDataFim())==0)
            {
                if(arrayHorario.getInts()>0)
                { for (int j=0;j<arrayHorario.getInts();j++){
                      if(funcoes.VerificaDatasInterrupcoes(data, arrayHorario.getIntI(j), arrayHorario.getIntF(j))==1 && arrayHorario.getNumAulasTerca()>0)
                      {
                        for(int i=0;i<arrayHorario.getNumAulasTerca();i++)
                        {
                            JLabel nova = new JLabel(arrayHorario.getAulaTerca(i));
                            JLabel nova1 = new JLabel(arrayHorario.getTipoAulaTerca(i)+"    "+arrayHorario.getLocalTerca(i));
                            JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioTerca(i)+" às "+arrayHorario.getHoraFimTerca(i));
                            nova.setSize(275, 20);                
                            nova.setLocation(pos_x,pos_y);
                            labelsCompromissos.add(nova);

                            nova1.setSize(275, 20);                
                            nova1.setLocation(pos_x,pos_y+20);
                            nova2.setSize(275, 20);                
                            nova2.setLocation(pos_x,pos_y+40);

                            BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                            novo.setSize(165, 60);
                            novo.setLocation(pos_x+270,pos_y);
                            buttonsCompromissos.add(novo);

                            labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                            panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                            panelCompromissos.add(nova1);
                            panelCompromissos.add(nova2);

                            buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                            buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                                new ActionListener()
                                {
                                    public void actionPerformed(ActionEvent arg0)
                                    {
                                        BotaoAlt x = (BotaoAlt) arg0.getSource();
                                        IndiceEliminarCompromisso=x.get_indice();
                                        DataEliminarCompromisso=DataAux;
                                        JanelaEliminarCompromisso.setVisible(true);
                                        JanelaEliminarCompromisso.setSize(260,90);
                                        panelCompromissos.setVisible(false);
                                        panelCompromissos.removeAll();
                                        panelCompromissos.updateUI();                            
                                    }
                                }
                            );

                            panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                            panelCompromissos.revalidate();
                            panelCompromissos.repaint();
                            pos_y=pos_y+60;
                        }
                    }
                }
            }
            else
            {for(int i=0;i<arrayHorario.getNumAulasTerca();i++)
                        {
                            JLabel nova = new JLabel(arrayHorario.getAulaTerca(i));
                            JLabel nova1 = new JLabel(arrayHorario.getTipoAulaTerca(i)+"    "+arrayHorario.getLocalTerca(i));
                            JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioTerca(i)+" às "+arrayHorario.getHoraFimTerca(i));
                            nova.setSize(275, 20);                
                            nova.setLocation(pos_x,pos_y);
                            labelsCompromissos.add(nova);

                            nova1.setSize(275, 20);                
                            nova1.setLocation(pos_x,pos_y+20);
                            nova2.setSize(275, 20);                
                            nova2.setLocation(pos_x,pos_y+40);

                            BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                            novo.setSize(165, 60);
                            novo.setLocation(pos_x+270,pos_y);
                            buttonsCompromissos.add(novo);

                            labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                            panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                            panelCompromissos.add(nova1);
                            panelCompromissos.add(nova2);

                            buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                            buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                                new ActionListener()
                                {
                                    public void actionPerformed(ActionEvent arg0)
                                    {
                                        BotaoAlt x = (BotaoAlt) arg0.getSource();
                                        IndiceEliminarCompromisso=x.get_indice();
                                        DataEliminarCompromisso=DataAux;
                                        JanelaEliminarCompromisso.setVisible(true);
                                        JanelaEliminarCompromisso.setSize(260,90);
                                        panelCompromissos.setVisible(false);
                                        panelCompromissos.removeAll();
                                        panelCompromissos.updateUI();                            
                                    }
                                }
                            );

                            panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                            panelCompromissos.revalidate();
                            panelCompromissos.repaint();
                            pos_y=pos_y+60;
                        }
            }
            }
            
            if(DiaSemana.equals("Qua") && funcoes.VerificaDatasHorario(data, arrayHorario.getDataInicio(), arrayHorario.getDataFim())==0 && arrayHorario.getNumAulasQuarta()>0)
            {
                 if(arrayHorario.getInts()>0)
                 {for (int j=0;j<arrayHorario.getInts();j++){
                      if(funcoes.VerificaDatasInterrupcoes(data, arrayHorario.getIntI(j), arrayHorario.getIntF(j))==1){
                for(int i=0;i<arrayHorario.getNumAulasQuarta();i++)
                {
                    JLabel nova = new JLabel(arrayHorario.getAulaQuarta(i));
                    JLabel nova1 = new JLabel(arrayHorario.getTipoAulaQuarta(i)+"    "+arrayHorario.getLocalQuarta(i));
                    JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioQuarta(i)+" às "+arrayHorario.getHoraFimQuarta(i));
                    nova.setSize(275, 20);                
                    nova.setLocation(pos_x,pos_y);
                    labelsCompromissos.add(nova);

                    nova1.setSize(275, 20);                
                    nova1.setLocation(pos_x,pos_y+20);
                    nova2.setSize(275, 20);                
                    nova2.setLocation(pos_x,pos_y+40);

                    BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                    novo.setSize(165, 60);
                    novo.setLocation(pos_x+270,pos_y);
                    buttonsCompromissos.add(novo);

                    labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                    panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                    panelCompromissos.add(nova1);
                    panelCompromissos.add(nova2);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                        new ActionListener()
                        {
                            public void actionPerformed(ActionEvent arg0)
                            {
                                BotaoAlt x = (BotaoAlt) arg0.getSource();
                                IndiceEliminarCompromisso=x.get_indice();
                                DataEliminarCompromisso=DataAux;
                                JanelaEliminarCompromisso.setVisible(true);
                                JanelaEliminarCompromisso.setSize(260,90);
                                panelCompromissos.setVisible(false);
                                panelCompromissos.removeAll();
                                panelCompromissos.updateUI();                            
                            }
                        }
                    );

                    panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                    panelCompromissos.revalidate();
                    panelCompromissos.repaint();
                    pos_y=pos_y+60;
                }
                      }
                      else
                      {
                          for(int i=0;i<arrayHorario.getNumAulasQuarta();i++)
                {
                    JLabel nova = new JLabel(arrayHorario.getAulaQuarta(i));
                    JLabel nova1 = new JLabel(arrayHorario.getTipoAulaQuarta(i)+"    "+arrayHorario.getLocalQuarta(i));
                    JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioQuarta(i)+" às "+arrayHorario.getHoraFimQuarta(i));
                    nova.setSize(275, 20);                
                    nova.setLocation(pos_x,pos_y);
                    labelsCompromissos.add(nova);

                    nova1.setSize(275, 20);                
                    nova1.setLocation(pos_x,pos_y+20);
                    nova2.setSize(275, 20);                
                    nova2.setLocation(pos_x,pos_y+40);

                    BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                    novo.setSize(165, 60);
                    novo.setLocation(pos_x+270,pos_y);
                    buttonsCompromissos.add(novo);

                    labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                    panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                    panelCompromissos.add(nova1);
                    panelCompromissos.add(nova2);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                        new ActionListener()
                        {
                            public void actionPerformed(ActionEvent arg0)
                            {
                                BotaoAlt x = (BotaoAlt) arg0.getSource();
                                IndiceEliminarCompromisso=x.get_indice();
                                DataEliminarCompromisso=DataAux;
                                JanelaEliminarCompromisso.setVisible(true);
                                JanelaEliminarCompromisso.setSize(260,90);
                                panelCompromissos.setVisible(false);
                                panelCompromissos.removeAll();
                                panelCompromissos.updateUI();                            
                            }
                        }
                    );

                    panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                    panelCompromissos.revalidate();
                    panelCompromissos.repaint();
                    pos_y=pos_y+60;
                }
                      }
            }
            }
            }
            if(DiaSemana.equals("Qui") && funcoes.VerificaDatasHorario(data, arrayHorario.getDataInicio(), arrayHorario.getDataFim())==0 && arrayHorario.getNumAulasQuinta()>0)
            {
                 if(arrayHorario.getInts()>0)
                 {for (int j=0;j<arrayHorario.getInts();j++){
              if(funcoes.VerificaDatasInterrupcoes(data, arrayHorario.getIntI(j), arrayHorario.getIntF(j))==1){
                     for(int i=0;i<arrayHorario.getNumAulasQuinta();i++)
                {
                    JLabel nova = new JLabel(arrayHorario.getAulaQuinta(i));
                    JLabel nova1 = new JLabel(arrayHorario.getTipoAulaQuinta(i)+"    "+arrayHorario.getLocalQuinta(i));
                    JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioQuinta(i)+" às "+arrayHorario.getHoraFimQuinta(i));
                    nova.setSize(275, 20);                
                    nova.setLocation(pos_x,pos_y);
                    labelsCompromissos.add(nova);

                    nova1.setSize(275, 20);                
                    nova1.setLocation(pos_x,pos_y+20);
                    nova2.setSize(275, 20);                
                    nova2.setLocation(pos_x,pos_y+40);

                    BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                    novo.setSize(165, 60);
                    novo.setLocation(pos_x+270,pos_y);
                    buttonsCompromissos.add(novo);

                    labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                    panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                    panelCompromissos.add(nova1);
                    panelCompromissos.add(nova2);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                        new ActionListener()
                        {
                            public void actionPerformed(ActionEvent arg0)
                            {
                                BotaoAlt x = (BotaoAlt) arg0.getSource();
                                IndiceEliminarCompromisso=x.get_indice();
                                DataEliminarCompromisso=DataAux;
                                JanelaEliminarCompromisso.setVisible(true);
                                JanelaEliminarCompromisso.setSize(260,90);
                                panelCompromissos.setVisible(false);
                                panelCompromissos.removeAll();
                                panelCompromissos.updateUI();                            
                            }
                        }
                    );

                    panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                    panelCompromissos.revalidate();
                    panelCompromissos.repaint();
                    pos_y=pos_y+60;
                }}
              else
              {
                  for(int i=0;i<arrayHorario.getNumAulasQuinta();i++)
                {
                    JLabel nova = new JLabel(arrayHorario.getAulaQuinta(i));
                    JLabel nova1 = new JLabel(arrayHorario.getTipoAulaQuinta(i)+"    "+arrayHorario.getLocalQuinta(i));
                    JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioQuinta(i)+" às "+arrayHorario.getHoraFimQuinta(i));
                    nova.setSize(275, 20);                
                    nova.setLocation(pos_x,pos_y);
                    labelsCompromissos.add(nova);

                    nova1.setSize(275, 20);                
                    nova1.setLocation(pos_x,pos_y+20);
                    nova2.setSize(275, 20);                
                    nova2.setLocation(pos_x,pos_y+40);

                    BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                    novo.setSize(165, 60);
                    novo.setLocation(pos_x+270,pos_y);
                    buttonsCompromissos.add(novo);

                    labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                    panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                    panelCompromissos.add(nova1);
                    panelCompromissos.add(nova2);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                        new ActionListener()
                        {
                            public void actionPerformed(ActionEvent arg0)
                            {
                                BotaoAlt x = (BotaoAlt) arg0.getSource();
                                IndiceEliminarCompromisso=x.get_indice();
                                DataEliminarCompromisso=DataAux;
                                JanelaEliminarCompromisso.setVisible(true);
                                JanelaEliminarCompromisso.setSize(260,90);
                                panelCompromissos.setVisible(false);
                                panelCompromissos.removeAll();
                                panelCompromissos.updateUI();                            
                            }
                        }
                    );

                    panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                    panelCompromissos.revalidate();
                    panelCompromissos.repaint();
                    pos_y=pos_y+60;
                }
              }
            }
            }}

            if(DiaSemana.equals("Sex") && funcoes.VerificaDatasHorario(data, arrayHorario.getDataInicio(), arrayHorario.getDataFim())==0 && arrayHorario.getNumAulasSexta()>0)
            {
                 if(arrayHorario.getInts()>0)
                 {for (int j=0;j<arrayHorario.getInts();j++){
                      if(funcoes.VerificaDatasInterrupcoes(data, arrayHorario.getIntI(j), arrayHorario.getIntF(j))==1){
                for(int i=0;i<arrayHorario.getNumAulasSegunda();i++)
                {
                    JLabel nova = new JLabel(arrayHorario.getAulaSexta(i));
                    JLabel nova1 = new JLabel(arrayHorario.getTipoAulaSexta(i)+"    "+arrayHorario.getLocalSexta(i));
                    JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioSexta(i)+" às "+arrayHorario.getHoraFimSexta(i));
                    nova.setSize(275, 20);                
                    nova.setLocation(pos_x,pos_y);
                    labelsCompromissos.add(nova);

                    nova1.setSize(275, 20);                
                    nova1.setLocation(pos_x,pos_y+20);
                    nova2.setSize(275, 20);                
                    nova2.setLocation(pos_x,pos_y+40);

                    BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                    novo.setSize(165, 60);
                    novo.setLocation(pos_x+270,pos_y);
                    buttonsCompromissos.add(novo);

                    labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                    panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                    panelCompromissos.add(nova1);
                    panelCompromissos.add(nova2);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                        new ActionListener()
                        {
                            public void actionPerformed(ActionEvent arg0)
                            {
                                BotaoAlt x = (BotaoAlt) arg0.getSource();
                                IndiceEliminarCompromisso=x.get_indice();
                                DataEliminarCompromisso=DataAux;
                                JanelaEliminarCompromisso.setVisible(true);
                                JanelaEliminarCompromisso.setSize(260,90);
                                panelCompromissos.setVisible(false);
                                panelCompromissos.removeAll();
                                panelCompromissos.updateUI();                            
                            }
                        }
                    );

                    panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                    panelCompromissos.revalidate();
                    panelCompromissos.repaint();
                    pos_y=pos_y+60;
                }
                      }
                      else
                      {
                          for(int i=0;i<arrayHorario.getNumAulasSegunda();i++)
                {
                    JLabel nova = new JLabel(arrayHorario.getAulaSexta(i));
                    JLabel nova1 = new JLabel(arrayHorario.getTipoAulaSexta(i)+"    "+arrayHorario.getLocalSexta(i));
                    JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioSexta(i)+" às "+arrayHorario.getHoraFimSexta(i));
                    nova.setSize(275, 20);                
                    nova.setLocation(pos_x,pos_y);
                    labelsCompromissos.add(nova);

                    nova1.setSize(275, 20);                
                    nova1.setLocation(pos_x,pos_y+20);
                    nova2.setSize(275, 20);                
                    nova2.setLocation(pos_x,pos_y+40);

                    BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                    novo.setSize(165, 60);
                    novo.setLocation(pos_x+270,pos_y);
                    buttonsCompromissos.add(novo);

                    labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                    panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                    panelCompromissos.add(nova1);
                    panelCompromissos.add(nova2);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                        new ActionListener()
                        {
                            public void actionPerformed(ActionEvent arg0)
                            {
                                BotaoAlt x = (BotaoAlt) arg0.getSource();
                                IndiceEliminarCompromisso=x.get_indice();
                                DataEliminarCompromisso=DataAux;
                                JanelaEliminarCompromisso.setVisible(true);
                                JanelaEliminarCompromisso.setSize(260,90);
                                panelCompromissos.setVisible(false);
                                panelCompromissos.removeAll();
                                panelCompromissos.updateUI();                            
                            }
                        }
                    );

                    panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                    panelCompromissos.revalidate();
                    panelCompromissos.repaint();
                    pos_y=pos_y+60;
                }
                      }
                            
            }
            }
            }
            if(DiaSemana.equals("Sáb") && funcoes.VerificaDatasHorario(data, arrayHorario.getDataInicio(), arrayHorario.getDataFim())==0)
            {
                 if(arrayHorario.getInts()>0)
                 {for (int j=0;j<arrayHorario.getInts();j++){
              if(funcoes.VerificaDatasInterrupcoes(data, arrayHorario.getIntI(j), arrayHorario.getIntF(j))==1){
                     for(int i=0;i<arrayHorario.getNumAulasSabado();i++)
                {
                    JLabel nova = new JLabel(arrayHorario.getAulaSabado(i));
                    JLabel nova1 = new JLabel(arrayHorario.getTipoAulaSabado(i)+"    "+arrayHorario.getLocalSabado(i));
                    JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioSabado(i)+" às "+arrayHorario.getHoraFimSabado(i));
                    nova.setSize(275, 20);                
                    nova.setLocation(pos_x,pos_y);
                    labelsCompromissos.add(nova);

                    nova1.setSize(275, 20);                
                    nova1.setLocation(pos_x,pos_y+20);
                    nova2.setSize(275, 20);                
                    nova2.setLocation(pos_x,pos_y+40);

                    BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                    novo.setSize(165, 60);
                    novo.setLocation(pos_x+270,pos_y);
                    buttonsCompromissos.add(novo);

                    labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                    panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                    panelCompromissos.add(nova1);
                    panelCompromissos.add(nova2);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                        new ActionListener()
                        {
                            public void actionPerformed(ActionEvent arg0)
                            {
                                BotaoAlt x = (BotaoAlt) arg0.getSource();
                                IndiceEliminarCompromisso=x.get_indice();
                                DataEliminarCompromisso=DataAux;
                                JanelaEliminarCompromisso.setVisible(true);
                                JanelaEliminarCompromisso.setSize(260,90);
                                panelCompromissos.setVisible(false);
                                panelCompromissos.removeAll();
                                panelCompromissos.updateUI();                            
                            }
                        }
                    );

                    panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                    panelCompromissos.revalidate();
                    panelCompromissos.repaint();
                    pos_y=pos_y+60;
                }
              }
              else
              {
                  for(int i=0;i<arrayHorario.getNumAulasSabado();i++)
                {
                    JLabel nova = new JLabel(arrayHorario.getAulaSabado(i));
                    JLabel nova1 = new JLabel(arrayHorario.getTipoAulaSabado(i)+"    "+arrayHorario.getLocalSabado(i));
                    JLabel nova2 = new JLabel("Das "+arrayHorario.getHoraInicioSabado(i)+" às "+arrayHorario.getHoraFimSabado(i));
                    nova.setSize(275, 20);                
                    nova.setLocation(pos_x,pos_y);
                    labelsCompromissos.add(nova);

                    nova1.setSize(275, 20);                
                    nova1.setLocation(pos_x,pos_y+20);
                    nova2.setSize(275, 20);                
                    nova2.setLocation(pos_x,pos_y+40);

                    BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                    novo.setSize(165, 60);
                    novo.setLocation(pos_x+270,pos_y);
                    buttonsCompromissos.add(novo);

                    labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                    panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                    panelCompromissos.add(nova1);
                    panelCompromissos.add(nova2);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);

                    buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                        new ActionListener()
                        {
                            public void actionPerformed(ActionEvent arg0)
                            {
                                BotaoAlt x = (BotaoAlt) arg0.getSource();
                                IndiceEliminarCompromisso=x.get_indice();
                                DataEliminarCompromisso=DataAux;
                                JanelaEliminarCompromisso.setVisible(true);
                                JanelaEliminarCompromisso.setSize(260,90);
                                panelCompromissos.setVisible(false);
                                panelCompromissos.removeAll();
                                panelCompromissos.updateUI();                            
                            }
                        }
                    );

                    panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                    panelCompromissos.revalidate();
                    panelCompromissos.repaint();
                    pos_y=pos_y+60;
                }
              }
            }
           }}
       }
       for (int i = 0; i < arrayCompromissos.size(); i++) 
       {
            System.err.println(arrayCompromissos.get(i).getData()+"\t"+data);
            if (arrayCompromissos.get(i).getData().equals(data)) 
            {                
                
                JLabel nova = new JLabel(arrayCompromissos.get(i).getCompromisso());
                JLabel nova1 = new JLabel("Local: "+arrayCompromissos.get(i).getLocal());
                JLabel nova2 = new JLabel("Das "+arrayCompromissos.get(i).getHoraInicio()+" às "+arrayCompromissos.get(i).getHoraFim());
                nova.setSize(275, 20);                
                nova.setLocation(pos_x,pos_y);
                labelsCompromissos.add(nova);
                
                nova1.setSize(275, 20);                
                nova1.setLocation(pos_x,pos_y+20);
                nova2.setSize(275, 20);                
                nova2.setLocation(pos_x,pos_y+40);
                
                BotaoAlt novo = new BotaoAlt(i, "Eliminar Compromisso");
                novo.setSize(165, 60);
                novo.setLocation(pos_x+270,pos_y);
                buttonsCompromissos.add(novo);
                
                labelsCompromissos.get(labelsCompromissos.size()-1).setVisible(true);
                panelCompromissos.add(labelsCompromissos.get(labelsCompromissos.size()-1)); 
                panelCompromissos.add(nova1);
                panelCompromissos.add(nova2);
                
                buttonsCompromissos.get(buttonsCompromissos.size()-1).setVisible(true);
                
                buttonsCompromissos.get(buttonsCompromissos.size()-1).addActionListener(
                    new ActionListener()
                    {
                        public void actionPerformed(ActionEvent arg0)
                        {
                            BotaoAlt x = (BotaoAlt) arg0.getSource();
                            IndiceEliminarCompromisso=x.get_indice();
                            DataEliminarCompromisso=DataAux;
                            JanelaEliminarCompromisso.setVisible(true);
                            JanelaEliminarCompromisso.setSize(260,90);
                            panelCompromissos.setVisible(false);
                            panelCompromissos.removeAll();
                            panelCompromissos.updateUI();                            
                        }
                    }
                );
               
                panelCompromissos.add(buttonsCompromissos.get(buttonsCompromissos.size()-1));
                panelCompromissos.revalidate();
                panelCompromissos.repaint();
                pos_y=pos_y+60;
            }
            panelCompromissos.setVisible(true);
            JanelaCompromissos.add(panelCompromissos);
            JanelaCompromissos.repaint();
            JanelaCompromissos.setLocationRelativeTo(null);
            JanelaCompromissos.setVisible(true);
        }
    }   
    
    private void VisualizarCalendarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VisualizarCalendarioActionPerformed
     //  try {
       //   LeHorario();
        //} catch (ParseException ex) {
         //   Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
       // }
        JanelaCompromissos.setVisible(true);       
        JanelaCompromissos.setSize(500, 500);
        
        setLocationRelativeTo(null);
    }//GEN-LAST:event_VisualizarCalendarioActionPerformed

    private void VisualizarTarefasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VisualizarTarefasActionPerformed
        JanelaVisualizacaoTarefas.setLocationRelativeTo(null); 
        JanelaVisualizacaoTarefas.setVisible(true);
        JanelaVisualizacaoTarefas.setSize(400, 400);        
        VisualizarTarefas();
    }//GEN-LAST:event_VisualizarTarefasActionPerformed
     
    private void Calendario1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_Calendario1PropertyChange
        SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); //DEFINE FORMATO DE DATA   
        SimpleDateFormat DayOfWeek = new SimpleDateFormat("EE"); //GET_DIA_SEMANA
        String data = formato.format(Calendario1.getDate()); //CONVERTE PRA STRING    
        DiaSemana = DayOfWeek.format(Calendario1.getDate());
        DataAux2=data;
        System.err.println(data);
        System.err.println(DiaSemana);
        try {
            VisualizarCompromissos(data);
        } catch (ParseException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_Calendario1PropertyChange

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
                    int flagSeg=0;
                    int flagTer=0;
                    int flagQua=0;
                    int flagQui=0;
                    int flagSex=0;
                    int flagSab=0;
                    int flagAux=0;
        String local = TextFieldLocal.getText();
        String compromisso = TextAreaCompromisso.getText();

        if (ListaHIcompromisso.isSelectionEmpty() || ListaHFcompromisso.isSelectionEmpty() || ListaMIcompromisso.isSelectionEmpty() || ListaMFCompromisso.isSelectionEmpty() || local.equals("") || compromisso.equals("")) {
            JOptionPane.showMessageDialog(this, "Campo/s não preenchido/s", "Informação", JOptionPane.WARNING_MESSAGE);
        } else {
            int HoraInicioH = Integer.parseInt(ListaHIcompromisso.getSelectedValue().toString());
            int HoraInicioM = Integer.parseInt(ListaMIcompromisso.getSelectedValue().toString());
            int HoraFimH = Integer.parseInt(ListaHFcompromisso.getSelectedValue().toString());
            int HoraFimM = Integer.parseInt(ListaMFCompromisso.getSelectedValue().toString());

            String HoraInicio = (HoraInicioH + ":" + HoraInicioM);
            String HoraFim = (HoraFimH + ":" + HoraFimM);

            try {
                if (funcoes.VerificaHoras(HoraInicio, HoraFim) == 1) {
                    JOptionPane.showMessageDialog(this, "A hora de fim não pode ser igual ou inferior à de início", "Aviso", JOptionPane.WARNING_MESSAGE);
                } else {
                    SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); //DEFINE FORMATO DE DATA    
                    String data = formato.format(Calendario1.getDate()); //CONVERTE PRA STRING 
                    
                   DateFormat datact = new SimpleDateFormat("yyyy/MM/dd");
                    Date da = new Date();
                    
                    

                   if(flagHorario!=0)
                    {
                        for(int x=0;x<arrayHorario.getInts();x++)
                        {
                            SimpleDateFormat form = new SimpleDateFormat("dd/MM/yyyy");  
                            Date d1=form.parse(arrayHorario.getIntI(x));
                            Date d2=form.parse(arrayHorario.getIntF(x));
                            
                            if(Calendario1.getDate().before(d1)  || Calendario1.getDate().after(d2))
                            {
                                if(DiaSemana.equals("Seg"))
                                {
                                    for(int i=0;i<arrayHorario.getNumAulasSegunda();i++)
                                    {
                                        if(funcoes.VerificaHorasAulasCompromissos2(arrayHorario.getHoraInicioSegunda(i), arrayHorario.getHoraFimSegunda(i), HoraInicio, HoraFim) == 0)  
                                        {
                                            System.out.println("CHEGUEI");
                                            flagAux++;
                                        }
                                    }
                                }

                                if(DiaSemana.equals("Ter"))
                                {
                                    for(int i=0;i<arrayHorario.getNumAulasTerca();i++)
                                    {
                                        if(funcoes.VerificaHorasAulasCompromissos2(arrayHorario.getHoraInicioTerca(i), arrayHorario.getHoraFimTerca(i), HoraInicio, HoraFim) == 0)  
                                        {
                                            flagAux++;
                                        }
                                    }
                                }
                        
                                if(DiaSemana.equals("Qua"))
                                {
                                    for(int i=0;i<arrayHorario.getNumAulasQuarta();i++)
                                    {
                                        if(funcoes.VerificaHorasAulasCompromissos2(arrayHorario.getHoraInicioQuarta(i), arrayHorario.getHoraFimQuarta(i), HoraInicio, HoraFim) == 0) 
                                        {
                                            flagAux++;
                                        }
                                    }
                                }
                        
                                if(DiaSemana.equals("Qui"))
                                {
                                    for(int i=0;i<arrayHorario.getNumAulasQuinta();i++)
                                    {
                                        if(funcoes.VerificaHorasAulasCompromissos2(arrayHorario.getHoraInicioQuinta(i), arrayHorario.getHoraFimQuinta(i), HoraInicio, HoraFim) == 0) 
                                        {
                                            flagAux++;
                                        }
                                    }
                                }
                        
                                if(DiaSemana.equals("Sex"))
                                {
                                    for(int i=0;i<arrayHorario.getNumAulasSexta();i++)
                                    {
                                        if(funcoes.VerificaHorasAulasCompromissos2(arrayHorario.getHoraInicioSexta(i), arrayHorario.getHoraFimSexta(i), HoraInicio, HoraFim) == 0) 
                                        {
                                            flagAux++;
                                        }
                                    }
                                }
                        
                                if(DiaSemana.equals("Sáb"))
                                {
                                    for(int i=0;i<arrayHorario.getNumAulasSabado();i++)
                                    {
                                        if(funcoes.VerificaHorasAulasCompromissos2(arrayHorario.getHoraInicioSabado(i), arrayHorario.getHoraFimSabado(i), HoraInicio, HoraFim) == 0) 
                                        {
                                            flagAux++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    
                    for(int i=0;i<arrayCompromissos.size();i++)
                    {
                        if(data.equals(arrayCompromissos.get(i).getData()))
                        {
                            if(funcoes.VerificaHorasAulasCompromissos2(arrayCompromissos.get(i).getHoraInicio(), arrayCompromissos.get(i).getHoraFim(), HoraInicio, HoraFim) == 0)
                            {
                                flagAux++;
                            }
                        }
                    }
                    System.out.println(flagAux);
                    System.out.println(da);
                    
                    if(Calendario1.getDate().after(da) && flagAux==0)
                    {
               
                       
                        compromissos comp = new compromissos(compromisso, local, HoraInicio, HoraFim, data);
                        arrayCompromissos.add(comp);
                        FormCompromisso.setVisible(false);
                        JOptionPane.showMessageDialog(this, "Compromisso adicionado com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
                        TextFieldLocal.setText("");
                        TextAreaCompromisso.setText("");
                        ListaHIcompromisso.clearSelection();
                        ListaMIcompromisso.clearSelection();
                        ListaHFcompromisso.clearSelection();
                        ListaMFCompromisso.clearSelection();
                        FormCompromisso.setVisible(false);
                        //VisualizarCompromissos(DataAux2);
                        
                        File file=new File("compromissos.xml");
                        file.delete();
                        Document ladoc=GravaDadosCompromissos();
                        JdomFunctions.escreverDocParaFicheiro(ladoc, "compromissos.xml");
                        
                        JanelaCompromissos.setVisible(true);
                        VisualizarCompromissos(DataAux2);
                        }
                        
                    
                    else
                        JOptionPane.showMessageDialog(this, "Nao e possivel adicionar o Compromisso", "Aviso", JOptionPane.WARNING_MESSAGE);
                    
                }
            } catch (ParseException ex) {
                Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void BotaoAddCompromissoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoAddCompromissoActionPerformed
        if(flagHorario==0)
        {
            JanelaContinuarComCompromisso.setVisible(true);
            JanelaContinuarComCompromisso.setSize(500,300);
        }
        else
        {
            JanelaCompromissos.setVisible(false);
            FormCompromisso.setLocationRelativeTo(null);
            FormCompromisso.setVisible(true);
            FormCompromisso.setSize(500, 400);
        }
    }//GEN-LAST:event_BotaoAddCompromissoActionPerformed

    private void AddTarefasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddTarefasActionPerformed
        //JanelaAddTarefas.TextAreaTarefa.setText("");
        JanelaAddTarefas.setLocationRelativeTo(null);
        JanelaAddTarefas.setVisible(true); 
        JanelaAddTarefas.setSize(400, 300);
     
    }//GEN-LAST:event_AddTarefasActionPerformed

    private void BotaoAddTarefaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoAddTarefaActionPerformed
        String tarefa = TextAreaTarefa.getText();

        if (tarefa.equals("")) {
            JOptionPane.showMessageDialog(this, "Campo não preenchido", "Informação", JOptionPane.WARNING_MESSAGE);
        } else {
            tarefas taref = new tarefas(tarefa);
            arrayTarefas.add(taref);
            JOptionPane.showMessageDialog(this, "Tarefa adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
            TextAreaTarefa.setText("");
            
            File file=new File("tarefas.xml");
            file.delete();
               Document ladoc=GravaDadosTarefas();
         JdomFunctions.escreverDocParaFicheiro(ladoc, "tarefas.xml");
        }
    }//GEN-LAST:event_BotaoAddTarefaActionPerformed

    private void PreencheHorarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PreencheHorarioActionPerformed

           //File file=new File("horario.xml");
            
           //file.delete();
         
      //  JanelaPreenchHorario.setVisible(true);
       // JanelaPreenchHorario.setSize(400, 300);

        if(flagHorario==0)
        {
            JanelaPreenchHorario.setVisible(true);
            JanelaPreenchHorario.setSize(400, 300);
        }
        else
        {
            FormularioAula.setVisible(true);
            FormularioAula.setSize(350, 400);
        }

    }//GEN-LAST:event_PreencheHorarioActionPerformed

    private void DateChooserInicioSemPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_DateChooserInicioSemPropertyChange
        Date dateFromDateChooser = DateChooserInicioSem.getDate();
        DataInicioSemestre = String.format("%1$td/%1$tm/%1$tY", dateFromDateChooser);
        System.err.println(DataInicioSemestre);
    }//GEN-LAST:event_DateChooserInicioSemPropertyChange

    private void DateChooserFimSemPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_DateChooserFimSemPropertyChange
        Date dateFromDateChooser = DateChooserFimSem.getDate();
        DataFimSemestre = String.format("%1$td/%1$tm/%1$tY", dateFromDateChooser);
        System.err.println(DataFimSemestre);
    }//GEN-LAST:event_DateChooserFimSemPropertyChange

    private void BotaoContinuarPreenchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoContinuarPreenchActionPerformed
        Date dateFromDateChooser1 = DateChooserInicioSem.getDate();
        String formato="%1$td/%1$tm/%1$tY";
        DataInicioSemestre = String.format(formato, dateFromDateChooser1);
        Date dateFromDateChooser2 = DateChooserFimSem.getDate();
        DataFimSemestre = String.format(formato, dateFromDateChooser2);

        if (DataInicioSemestre.equals("null/null/null") || DataFimSemestre.equals("null/null/null")) {
            JOptionPane.showMessageDialog(this, "Data/s não preenchida/s", "Informação", JOptionPane.WARNING_MESSAGE);
        } else {
            if (funcoes.VerificaDatas(DataInicioSemestre, DataFimSemestre) == 1) {
                JOptionPane.showMessageDialog(this, "A data de fim não pode ser igual ou inferior à de início", "Aviso", JOptionPane.WARNING_MESSAGE);
            } else {
                horario hor = new horario(DataInicioSemestre, DataFimSemestre);
                arrayHorario = hor;
                flagHorario=1;
                DataInicioSemestre = "null/null/null";
                DataFimSemestre = "null/null/null";
                JanelaPreenchHorario.setVisible(false);
                FormularioAula.setVisible(true);
                FormularioAula.setSize(350, 400);
            }
        }
    }//GEN-LAST:event_BotaoContinuarPreenchActionPerformed

    private void DateChooserFimSem2PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_DateChooserFimSem2PropertyChange
        Date dateFromDateChooser = DateChooserFimSem2.getDate();
        DataFimInterrupcao = String.format("%1$td/%1$tm/%1$tY", dateFromDateChooser);
        System.err.println(DataInicioInterrupcao);
    }//GEN-LAST:event_DateChooserFimSem2PropertyChange

    private void jDateChooser4PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jDateChooser4PropertyChange
        Date dateFromDateChooser = jDateChooser4.getDate();
        DataInicioInterrupcao = String.format("%1$td/%1$tm/%1$tY", dateFromDateChooser);
        System.err.println(DataInicioInterrupcao);
    }//GEN-LAST:event_jDateChooser4PropertyChange

    @SuppressWarnings("empty-statement")
    private void BotaoContinuaPreench2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoContinuaPreench2ActionPerformed

         if (DataInicioInterrupcao.equals("null/null/null") || DataFimInterrupcao.equals("null/null/null")) 
         {
             JOptionPane.showMessageDialog(this, "Data/s não preenchida/s", "Informação", JOptionPane.WARNING_MESSAGE);
         } 
         else 
         {
             int flag=0;
             
             if(funcoes.VerificaDatas(DataInicioInterrupcao, DataFimInterrupcao)==1)
                 flag++;
             
             try {
                 if(funcoes.VerificaDatasAddInterrupcao(DataInicioInterrupcao, DataFimInterrupcao, arrayHorario.getDataInicio(), arrayHorario.getDataFim())==0)
                     flag++;
             } catch (ParseException ex) {
                 Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
             }
             
             for(int i=0;i<arrayHorario.getInts();i++)
                 try {
                     if(funcoes.VerificaDatasAddInterrupcao(DataInicioInterrupcao, DataFimInterrupcao, arrayHorario.getIntI(i), arrayHorario.getIntF(i))==1)
                         flag++;
                 } catch (ParseException ex) {
                     Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                 }
                     
             if(flag==0)
             {
                interrupcoes nova=new interrupcoes(DataInicioInterrupcao,DataFimInterrupcao);
               
                arrayHorario.addInterrupcao(nova);
                JOptionPane.showMessageDialog(this, "Interrupção adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
                DataInicioInterrupcao = "null/null/null";
                DataFimInterrupcao = "null/null/null";
                JanelaInterrupcoes.setVisible(false);
                FormularioAula.setVisible(true);

                FormularioAula.setSize(350, 400);

                
                File file=new File("horario.xml");
                file.delete();
                Document ladoc=gravaDadosHorario();
                JdomFunctions.escreverDocParaFicheiro(ladoc, "horario.xml");
             }
             else
                 JOptionPane.showMessageDialog(this, "Interrupção não adicionada", "Confirmação", JOptionPane.WARNING_MESSAGE);   
         }
    }//GEN-LAST:event_BotaoContinuaPreench2ActionPerformed

    private void BotaoAddInterrupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoAddInterrupActionPerformed
       JanelaInterrupcoes.setVisible(true);
       JanelaInterrupcoes.setSize(400, 300);
    }//GEN-LAST:event_BotaoAddInterrupActionPerformed

    private void BotaoAddAulaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoAddAulaActionPerformed

        String aula = TextFieldNomeAula.getText();
        String local = TextFieldLocalAula.getText();
        
        if (ListaDias.isSelectionEmpty() || ListaHoraInicio.isSelectionEmpty() || ListaMinutosInicio.isSelectionEmpty() || ListaMinutosFim.isSelectionEmpty() || ListaHoraFim.isSelectionEmpty() || aula.equals("") || local.equals("")) {
            JOptionPane.showMessageDialog(this, "Campo não preenchido", "Informação", JOptionPane.WARNING_MESSAGE);
        } else {
            String DiaSemanaLocal = ListaDias.getSelectedValue().toString();
            String TipoAula = ListaTipoAula.getSelectedValue().toString();
            
            int HoraInicioH = Integer.parseInt(ListaHoraInicio.getSelectedValue().toString());
            int HoraInicioM = Integer.parseInt(ListaMinutosInicio.getSelectedValue().toString());
            int HoraFimH = Integer.parseInt(ListaHoraFim.getSelectedValue().toString());
            int HoraFimM = Integer.parseInt(ListaMinutosFim.getSelectedValue().toString());

            String HoraInicio = (HoraInicioH + ":" + HoraInicioM);
            String HoraFim = (HoraFimH + ":" + HoraFimM);
            try {
                if (funcoes.VerificaHoras(HoraInicio, HoraFim) == 1) 
                {
                    JOptionPane.showMessageDialog(this, "A hora de fim não pode ser igual ou inferior à de início", "Aviso", JOptionPane.WARNING_MESSAGE);
                }
                else 
                {
                    aula nova = new aula(aula, TipoAula, local, HoraInicio, HoraFim);
                    int flagSeg=0;
                    int flagTer=0;
                    int flagQua=0;
                    int flagQui=0;
                    int flagSex=0;
                    int flagSab=0;
                    
                    
                    if(DiaSemanaLocal.equals("Segunda-feira"))
                    {
                        if(arrayHorario.getNumAulasSegunda()==0)
                        {
                            arrayHorario.addAulaSegunda(nova);
                            JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
                            //System.err.println(arrayHorario.getAulaSegunda(0));
                        }
                        else
                        {     
                            for(int i=0 ;i<arrayHorario.getNumAulasSegunda();i++)
                            {
                                if(funcoes.VerificaHorasAulasCompromissos2(arrayHorario.getHoraInicioSegunda(i), arrayHorario.getHoraFimSegunda(i), HoraInicio, HoraFim)==1)
                                {
                                    flagSeg++;
                                }
                            }                                
                            if(flagSeg==1)
                            {
                                arrayHorario.addAulaSegunda(nova);
                                JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);        
                            }
                            else
                                JOptionPane.showMessageDialog(this, "Aula sobreposta com uma já existente", "Aviso", JOptionPane.WARNING_MESSAGE);
                        }
                    }
                    
                    if(DiaSemanaLocal.equals("Terça-feira"))
                    {
                        if(arrayHorario.getNumAulasTerca()==0)
                        {
                            arrayHorario.addAulaTerca(nova);
                            JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
                        }
                        else
                        {     
                            for(int i=0 ;i<arrayHorario.getNumAulasTerca();i++)
                            {
                                if(funcoes.VerificaHorasAulasCompromissos(arrayHorario.getHoraInicioTerca(i), arrayHorario.getHoraFimTerca(i), HoraInicio, HoraFim)==1)
                                {
                                    flagTer++;
                                }
                            }
                                
                            if(flagTer==1)
                            {
                                arrayHorario.addAulaTerca(nova);
                                JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);        
                            }
                            else
                                JOptionPane.showMessageDialog(this, "Aula sobreposta com uma já existente", "Aviso", JOptionPane.WARNING_MESSAGE);
                        }
                    }
                    
                    if(DiaSemanaLocal.equals("Quarta-feira"))
                    {
                        if(arrayHorario.getNumAulasQuarta()==0)
                        {
                            arrayHorario.addAulaQuarta(nova);
                            JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
                        }
                        else
                        {     
                            for(int i=0 ;i<arrayHorario.getNumAulasQuarta();i++)
                            {
                                if(funcoes.VerificaHorasAulasCompromissos(arrayHorario.getHoraInicioQuarta(i), arrayHorario.getHoraFimQuarta(i), HoraInicio, HoraFim)==1)
                                {
                                    flagQua++;
                                }
                            }
                                
                            if(flagQua==1)
                            {
                                arrayHorario.addAulaQuarta(nova);
                                JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);        
                            }
                            else
                                JOptionPane.showMessageDialog(this, "Aula sobreposta com uma já existente", "Aviso", JOptionPane.WARNING_MESSAGE);
                        }
                    }
                    
                    if(DiaSemanaLocal.equals("Quinta-feira"))
                    {
                        if(arrayHorario.getNumAulasQuinta()==0)
                        {
                            arrayHorario.addAulaQuinta(nova);
                            JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
                        }
                        else
                        {     
                            for(int i=0 ;i<arrayHorario.getNumAulasQuinta();i++)
                            {
                                if(funcoes.VerificaHorasAulasCompromissos(arrayHorario.getHoraInicioQuinta(i), arrayHorario.getHoraFimQuinta(i), HoraInicio, HoraFim)==1)
                                {
                                    flagQui++;
                                }
                            }
                                
                            if(flagQui==1)
                            {
                                arrayHorario.addAulaQuinta(nova);
                                JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);        
                            }
                            else
                                JOptionPane.showMessageDialog(this, "Aula sobreposta com uma já existente", "Aviso", JOptionPane.WARNING_MESSAGE);
                        }
                    }
                    
                    if(DiaSemanaLocal.equals("Sexta-feira"))
                    {
                        if(arrayHorario.getNumAulasSexta()==0)
                        {
                            arrayHorario.addAulaSexta(nova);
                            JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
                        }
                        else
                        {     
                            for(int i=0 ;i<arrayHorario.getNumAulasSexta();i++)
                            {
                                if(funcoes.VerificaHorasAulasCompromissos(arrayHorario.getHoraInicioSexta(i), arrayHorario.getHoraFimSexta(i), HoraInicio, HoraFim)==0)
                                {
                                    flagSex++;
                                }
                            }
                                
                            if(flagSex==1)
                            {
                                arrayHorario.addAulaSexta(nova);
                                JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);        
                            }
                            else
                                JOptionPane.showMessageDialog(this, "Aula sobreposta com uma já existente", "Aviso", JOptionPane.WARNING_MESSAGE);
                        }
                    }
                    
                    if(DiaSemanaLocal.equals("Sábado"))
                    {
                        if(arrayHorario.getNumAulasSabado()==0)
                        {
                            arrayHorario.addAulaSabado(nova);
                            JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
                        }
                        else
                        {     
                            for(int i=0 ;i<arrayHorario.getNumAulasSabado();i++)
                            {
                                if(funcoes.VerificaHorasAulasCompromissos(arrayHorario.getHoraInicioSabado(i), arrayHorario.getHoraFimSabado(i), HoraInicio, HoraFim)==1)
                                {
                                    flagSab++;
                                }
                            }
                                
                            if(flagSab==1)
                            {
                                arrayHorario.addAulaSabado(nova);
                                JOptionPane.showMessageDialog(this, "Aula adicionada com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);        
                            }
                            else
                                JOptionPane.showMessageDialog(this, "Aula sobreposta com uma já existente", "Aviso", JOptionPane.WARNING_MESSAGE);
                        }
                    }
                    
                    TextFieldNomeAula.setText("");
                    TextFieldLocalAula.setText("");
                    ListaHoraInicio.clearSelection();
                    ListaMinutosInicio.clearSelection();
                    ListaHoraFim.clearSelection();
                    ListaMinutosFim.clearSelection();
                    ListaDias.clearSelection();
                    ListaTipoAula.clearSelection();
                }
            } catch (ParseException ex) {
                Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
            }
                
        }
        
        File file=new File("horario.xml");
        file.delete();
        Document ladoc=gravaDadosHorario();
        JdomFunctions.escreverDocParaFicheiro(ladoc, "horario.xml");        
    }//GEN-LAST:event_BotaoAddAulaActionPerformed

    private void EliminarHorarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EliminarHorarioActionPerformed

         boolean deteta=(new File("horario.xml")).exists();
       if(deteta){
        
        JanelaEliminarHorario.setLocationRelativeTo(null);
       
        JanelaEliminarHorario.setVisible(true);
        JanelaEliminarHorario.setSize(320,130);
        }
        else
        JOptionPane.showMessageDialog(this, "Não existe um horario definido!", "Aviso", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_EliminarHorarioActionPerformed

    private void ConfirmarEliminarTarefaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfirmarEliminarTarefaActionPerformed
        ArrayList<tarefas> arrayTarefasAux = new ArrayList<tarefas>();
        
        for(int i=0;i<arrayTarefas.size();i++)
            if(i!=IndiceEliminarTarefa)
                arrayTarefasAux.add(arrayTarefas.get(i));
        
        arrayTarefas.clear();
        
        for(int i=0;i<arrayTarefasAux.size();i++)
            arrayTarefas.add(arrayTarefasAux.get(i));
            
        arrayTarefasAux.clear();
        JanelaEliminarTarefa.setVisible(false);
        
        File file=new File("tarefas.xml");
        file.delete();
        Document ladoc=GravaDadosTarefas();
        JdomFunctions.escreverDocParaFicheiro(ladoc, "tarefas.xml");
        
        VisualizarTarefas();
        
    }//GEN-LAST:event_ConfirmarEliminarTarefaActionPerformed

    private void CancelarEliminarTarefaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelarEliminarTarefaActionPerformed
        JanelaEliminarTarefa.setVisible(false);
    }//GEN-LAST:event_CancelarEliminarTarefaActionPerformed
    
    private void ConfirmarEliminarHorarioActionPerformed(java.awt.event.ActionEvent evt) {
    
          
      }
      
    private void ConfirmarEliminarCompromissoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfirmarEliminarCompromissoActionPerformed
        JanelaCompromissos.setVisible(false);
        ArrayList<compromissos> arrayCompromissosAux = new ArrayList<compromissos>();
        
        for(int i=0;i<arrayCompromissos.size();i++)
            if(i!=IndiceEliminarCompromisso)
                arrayCompromissosAux.add(arrayCompromissos.get(i));
        
        arrayCompromissos.clear();
        
        for(int i=0;i<arrayCompromissosAux.size();i++)
            arrayCompromissos.add(arrayCompromissosAux.get(i));
            
        arrayCompromissosAux.clear();
        JanelaEliminarCompromisso.setVisible(false);
        
        File file=new File("compromissos.xml");
        file.delete();
        Document ladoc=GravaDadosCompromissos();
        JdomFunctions.escreverDocParaFicheiro(ladoc, "compromissos.xml");
        
        JanelaCompromissos.setVisible(true);
    }//GEN-LAST:event_ConfirmarEliminarCompromissoActionPerformed

    private void CancelarEliminarCompromissoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelarEliminarCompromissoActionPerformed
        JanelaEliminarCompromisso.setVisible(false);
    }//GEN-LAST:event_CancelarEliminarCompromissoActionPerformed
    
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        JanelaEliminarHorario.setVisible(false);
        arrayHorario = null;
        flagHorario=0;
        File file=new File("horario.xml");
        file.delete();
        JOptionPane.showMessageDialog(this, "Horário eliminado com sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        
        JanelaEliminarHorario.setVisible(false);
    }//GEN-LAST:event_jButton7ActionPerformed

    private void TextFieldNomeAulaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextFieldNomeAulaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TextFieldNomeAulaActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        newFlagHorario=1;
        JanelaContinuarComCompromisso.setVisible(false);
        JanelaCompromissos.setVisible(false);
        FormCompromisso.setLocationRelativeTo(null);
        FormCompromisso.setVisible(true);
        FormCompromisso.setSize(500, 400);
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        newFlagHorario=0;
        JanelaContinuarComCompromisso.setVisible(false);
    }//GEN-LAST:event_jButton9ActionPerformed

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new GUI().setVisible(true);
                } catch (ParseException ex) {
                    Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem AddTarefas;
    private javax.swing.JMenuBar BarraMenu;
    private javax.swing.JButton BotaoAddAula;
    private javax.swing.JButton BotaoAddCompromisso;
    private javax.swing.JButton BotaoAddInterrup;
    private javax.swing.JButton BotaoAddTarefa;
    private javax.swing.JButton BotaoContinuaPreench2;
    private javax.swing.JButton BotaoContinuarPreench;
    private javax.swing.JMenu Calendario;
    private com.toedter.calendar.JCalendar Calendario1;
    private javax.swing.JButton CancelarEliminarCompromisso;
    private javax.swing.JButton CancelarEliminarTarefa;
    private javax.swing.JButton ConfirmarEliminarCompromisso;
    private javax.swing.JButton ConfirmarEliminarTarefa;
    private com.toedter.calendar.JDateChooser DateChooserFimSem;
    private com.toedter.calendar.JDateChooser DateChooserFimSem2;
    private com.toedter.calendar.JDateChooser DateChooserInicioSem;
    private javax.swing.JMenuItem EliminarHorario;
    private javax.swing.JDialog FormCompromisso;
    private javax.swing.JDialog FormularioAula;
    private javax.swing.JDialog JanelaAddTarefas;
    private javax.swing.JDialog JanelaCompromissos;
    private javax.swing.JDialog JanelaContinuarComCompromisso;
    private javax.swing.JDialog JanelaEliminarCompromisso;
    private javax.swing.JDialog JanelaEliminarHorario;
    private javax.swing.JDialog JanelaEliminarTarefa;
    private javax.swing.JDialog JanelaInterrupcoes;
    private javax.swing.JDialog JanelaPreenchHorario;
    private javax.swing.JDialog JanelaVisualizacaoTarefas;
    private javax.swing.JLabel LabelAula;
    private javax.swing.JLabel LabelCompromisso;
    private javax.swing.JLabel LabelCompromissos;
    private javax.swing.JLabel LabelDiaSemana;
    private javax.swing.JLabel LabelFimAula;
    private javax.swing.JLabel LabelFimInterrupcao;
    private javax.swing.JLabel LabelFimSemestre;
    private javax.swing.JLabel LabelH;
    private javax.swing.JLabel LabelH2;
    private javax.swing.JLabel LabelHoraFim;
    private javax.swing.JLabel LabelHoraInicio;
    private javax.swing.JLabel LabelHorario;
    private javax.swing.JLabel LabelInicioAula;
    private javax.swing.JLabel LabelInicioInt;
    private javax.swing.JLabel LabelInicioSemestre;
    private javax.swing.JLabel LabelLocal;
    private javax.swing.JLabel LabelM;
    private javax.swing.JLabel LabelM2;
    private javax.swing.JLabel LabelNomeAula;
    private javax.swing.JLabel LabelTarefas;
    private javax.swing.JLabel LabelTipo;
    private javax.swing.JList ListaDias;
    private javax.swing.JList ListaHFcompromisso;
    private javax.swing.JList ListaHIcompromisso;
    private javax.swing.JList ListaHoraFim;
    private javax.swing.JList ListaHoraInicio;
    private javax.swing.JList ListaMFCompromisso;
    private javax.swing.JList ListaMIcompromisso;
    private javax.swing.JList ListaMinutosFim;
    private javax.swing.JList ListaMinutosInicio;
    private javax.swing.JList ListaTipoAula;
    private javax.swing.JMenuItem PreencheHorario;
    private javax.swing.JMenu Tarefas;
    private javax.swing.JTextArea TextAreaCompromisso;
    private javax.swing.JTextArea TextAreaTarefa;
    private javax.swing.JTextField TextFieldLocal;
    private javax.swing.JTextField TextFieldLocalAula;
    private javax.swing.JTextField TextFieldNomeAula;
    private javax.swing.JMenuItem VisualizarCalendario;
    private javax.swing.JMenuItem VisualizarTarefas;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private com.toedter.calendar.JDateChooser jDateChooser4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    public javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JLabel labeltitulo;
    private javax.swing.JLabel nome1;
    private javax.swing.JLabel nome2;
    private javax.swing.JLabel nome3;
    private javax.swing.JLabel nome4;
    private javax.swing.JLabel nome5;
    // End of variables declaration//GEN-END:variables
}